Up-port new stuff from hr_holidays_usability from 7.0 to 8.0

This commit is contained in:
Alexis de Lattre
2015-06-23 16:29:47 +02:00
parent 219ec0e671
commit 1ff2416435
19 changed files with 1095 additions and 36 deletions

View File

@@ -21,3 +21,5 @@
##############################################################################
from . import hr_holidays
from . import wizard
from . import report

View File

@@ -32,8 +32,15 @@
'website': 'http://www.akretion.com',
'depends': ['hr_holidays', 'hr_public_holidays'],
'data': [
'wizard/hr_holidays_mass_allocation_view.xml',
'wizard/hr_holidays_post_view.xml',
'report/hr_holidays_employee_counter_view.xml',
'hr_holidays_view.xml',
'hr_holidays_mail.xml',
'res_company_view.xml',
'hr_employee_view.xml',
'security/holiday_security.xml',
'security/ir.model.access.csv',
],
'installable': True,
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_employee_form_leave_inherit" model="ir.ui.view">
<field name="name">hr_holidays_usability.hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr_holidays.view_employee_form_leave_inherit"/>
<field name="arch" type="xml">
<group string="Leaves" position="attributes">
<attribute name="invisible">1</attribute>
</group>
</field>
</record>
</data>
</openerp>

View File

@@ -146,16 +146,40 @@ class HrHolidays(models.Model):
break
date_dt += relativedelta(days=1)
self.number_of_days_remove = days
# PASTE
if self.type == 'remove':
# read number_of_days_remove instead of number_of_days_temp
number_of_days = -days
number_of_days = days * -1
number_of_days_remove = days
else:
# for allocations, we read the native field number_of_days_temp
number_of_days = self.number_of_days_temp
number_of_days_remove = 0
self.number_of_days = number_of_days
self.number_of_days_remove = number_of_days_remove
@api.one
@api.depends('holiday_type', 'employee_id', 'holiday_status_id')
def _compute_current_leaves(self):
total_allocated_leaves = 0
current_leaves_taken = 0
current_remaining_leaves = 0
if (
self.holiday_type == 'employee' and
self.employee_id and
self.holiday_status_id):
days = self.holiday_status_id.get_days(
self.employee_id.id, False)
total_allocated_leaves =\
days[self.holiday_status_id.id]['max_leaves']
current_leaves_taken =\
days[self.holiday_status_id.id]['leaves_taken']
current_remaining_leaves =\
days[self.holiday_status_id.id]['remaining_leaves']
self.total_allocated_leaves = total_allocated_leaves
self.current_leaves_taken = current_leaves_taken
self.current_remaining_leaves = current_remaining_leaves
vacation_date_from = fields.Date(
string='First Day of Vacation', track_visibility='onchange',
@@ -186,6 +210,19 @@ class HrHolidays(models.Model):
string="Number of Days of Vacation", readonly=True)
# number_of_days is a native field that I inherit
number_of_days = fields.Float(compute='_compute_number_of_days')
current_leaves_taken = fields.Float(
compute='_compute_current_leaves', string='Current Leaves Taken',
readonly=True)
current_remaining_leaves = fields.Float(
compute='_compute_current_leaves', string='Current Remaining Leaves',
readonly=True)
total_allocated_leaves = fields.Float(
compute='_compute_current_leaves', string='Total Allocated Leaves',
readonly=True)
limit = fields.Boolean(
related='holiday_status_id.limit', string='Allow to Override Limit')
posted_date = fields.Date(
string='Posted Date', track_visibility='onchange')
@api.one
@api.constrains(
@@ -268,3 +305,13 @@ class HrHolidays(models.Model):
datetime_str = fields.Datetime.to_string(
datetime_dt.astimezone(pytz.utc))
self.date_to = datetime_str
# in v8, no more need to inherit check_holidays() as I did in v8
# because it doesn't use number_of_days_temp
class ResCompany(models.Model):
_inherit = 'res.company'
mass_allocation_default_holiday_status_id = fields.Many2one(
'hr.holidays.status', string='Default Leave Type for Mass Allocation')

View File

@@ -84,7 +84,7 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force
<li>Start date : ${object.vacation_date_from or ''} ${object.vacation_time_from or ''}</li>
<li>End date : ${object.vacation_date_to or ''} ${object.vacation_time_to or ''}</li>
% endif
<li>Number of days : ${object.number_of_days or '0'}</li>
<li>Number of days : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}</li>
<li>Leave type : ${object.holiday_status_id.name or ''}</li>
<li>Description : ${object.name or ''}</li>
% if object.notes:

View File

@@ -38,6 +38,29 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
<field name="vacation_date_to" attrs="{'required': [('type', '=', 'remove')], 'invisible': [('type', '=', 'add')]}"/>
<field name="vacation_time_to" attrs="{'required': [('type', '=', 'remove')], 'invisible': [('type', '=', 'add')]}"/>
</field>
<xpath expr="//field[@name='department_id']/.." position="after">
<group string="Counter for this leave type" name="counters" attrs="{'invisible': [('limit', '=', True)]}">
<field name="limit" invisible="1"/>
<label for="total_allocated_leaves"/>
<div>
<field name="total_allocated_leaves" class="oe_inline"/>
<label string=" days" class="oe_inline"/>
</div>
<label for="current_leaves_taken"/>
<div>
<field name="current_leaves_taken" class="oe_inline"/>
<label string=" days" class="oe_inline"/>
</div>
<label for="current_remaining_leaves"/>
<div>
<field name="current_remaining_leaves" class="oe_inline"/>
<label string=" days" class="oe_inline"/>
</div>
</group>
</xpath>
<field name="department_id" position="after">
<field name="posted_date" groups="base.group_hr_user"/>
</field>
</field>
</record>
@@ -50,7 +73,7 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
<attribute name="invisible">1</attribute>
</field>
<field name="number_of_days" position="after">
<field name="number_of_days_remove"/>
<field name="number_of_days_remove" sum="Total Days of Vacation"/>
</field>
<field name="date_from" position="attributes">
<attribute name="invisible">1</attribute>
@@ -69,6 +92,9 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation -->
<field name="holiday_status_id" position="attributes">
<attribute name="invisible">0</attribute>
</field>
<field name="holiday_status_id" position="after">
<field name="posted_date" groups="base.group_hr_user"/>
</field>
</field>
</record>

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-18 21:36+0000\n"
"PO-Revision-Date: 2015-05-18 21:36+0000\n"
"POT-Creation-Date: 2015-06-19 16:56+0000\n"
"PO-Revision-Date: 2015-06-19 16:56+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -47,7 +47,7 @@ msgid "\n"
"% endif\n"
"</li>\n"
"% endif\n"
"<li>Nombre de jours : ${object.number_of_days_temp or '0'}</li>\n"
"<li>Nombre de jours : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}</li>\n"
"<li>Type de congé : ${object.holiday_status_id.name or ''}</li>\n"
"<li>Description : ${object.name or ''}</li>\n"
"% if object.notes:\n"
@@ -99,7 +99,7 @@ msgstr "\n"
"% endif\n"
"</li>\n"
"% endif\n"
"<li>Nombre de jours : ${object.number_of_days_temp or '0'}</li>\n"
"<li>Nombre de jours : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}</li>\n"
"<li>Type de congé : ${object.holiday_status_id.name or ''}</li>\n"
"<li>Description : ${object.name or ''}</li>\n"
"% if object.notes:\n"
@@ -122,11 +122,26 @@ msgstr "\n"
"</div>\n"
""
#. module: hr_holidays_usability
#: view:hr.holidays:0
msgid " days"
msgstr " jours"
#. module: hr_holidays_usability
#: model:email.template,subject:hr_holidays_usability.email_template_hr_holidays
msgid "${ctx.get('dbname') and 'prod' not in ctx.get('dbname') and '[TEST]' or ''}[${object.type == 'remove' and 'Demande' or 'Attribution'} de congé ${ctx.get('wkf_tracker')}] ${object.name or ''} - ${object.employee_id.name or ''}"
msgstr "${ctx.get('dbname') and 'prod' not in ctx.get('dbname') and '[TEST]' or ''}[${object.type == 'remove' and 'Demande' or 'Attribution'} de congé ${ctx.get('wkf_tracker')}] ${object.name or ''} - ${object.employee_id.name or ''}"
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,allocated_leaves:0
msgid "Allocated Leaves"
msgstr "Congés attribués"
#. module: hr_holidays_usability
#: field:hr.holidays,limit:0
msgid "Allow to Override Limit"
msgstr "Allow to Override Limit"
#. module: hr_holidays_usability
#: model:ir.actions.server,name:hr_holidays_usability.ir_actions_server_hr_holidays_confirm_mail
msgid "Auto-email confirmed leave"
@@ -142,6 +157,90 @@ msgstr "Auto-email refused leave"
msgid "Auto-email validated leave"
msgstr "Auto-email validated leave"
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,auto_approve:0
msgid "Automatic Approval"
msgstr "Validation automatique"
#. module: hr_holidays_usability
#: view:hr.holidays.mass.allocation:0
#: view:hr.holidays.post:0
msgid "Cancel"
msgstr "Annuler"
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_res_company
msgid "Companies"
msgstr "Sociétés"
#. module: hr_holidays_usability
#: view:hr.holidays:0
msgid "Counter for this leave type"
msgstr "Compteur pour ce type de congé"
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.hr_holidays_employee_counter_action
#: model:ir.ui.menu,name:hr_holidays_usability.hr_holidays_employee_counter_menu
msgid "Counters"
msgstr "Compteurs"
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_employee_counter
msgid "Counters for holidays of employees"
msgstr "Counters for holidays of employees"
#. module: hr_holidays_usability
#: view:hr.holidays.mass.allocation:0
msgid "Create Allocations"
msgstr "Créer des attributions"
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,leaves_validated_current:0
msgid "Current Leaves Validated"
msgstr "Congés validés"
#. module: hr_holidays_usability
#: field:hr.holidays,current_remaining_leaves:0
#: field:hr.holidays.employee.counter,leaves_remaining_current:0
msgid "Current Remaining Leaves"
msgstr "Solde de congés"
#. module: hr_holidays_usability
#: field:res.company,mass_allocation_default_holiday_status_id:0
msgid "Default Leave Type for Mass Allocation"
msgstr "Type de congé par défaut pour attribution en masse"
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,name:0
msgid "Description"
msgstr "Description"
#. module: hr_holidays_usability
#: selection:hr.holidays.post,state:0
msgid "Done"
msgstr "Done"
#. module: hr_holidays_usability
#: selection:hr.holidays.post,state:0
msgid "Draft"
msgstr "Draft"
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
#: field:hr.holidays.employee.counter,employee_id:0
msgid "Employee"
msgstr "Employé"
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
msgid "Employee Holidays Counters"
msgstr "Compteurs de congé de l'employé"
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,employee_ids:0
msgid "Employees"
msgstr "Employés"
#. module: hr_holidays_usability
#: field:hr.holidays,vacation_time_to:0
msgid "End of Vacation"
@@ -158,12 +257,15 @@ msgid "Enter the last day of vacation. For example, if you leave one full calend
msgstr "Entrez le dernier jour de congé. Par exemple, si vous partez en congé pendant une semaine calendaire, le dernier jour de congé est le vendredi soir (et non le lundi matin de la semaine suivante)"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:196
#: code:addons/hr_holidays_usability/hr_holidays.py:202
#: code:addons/hr_holidays_usability/hr_holidays.py:209
#: code:addons/hr_holidays_usability/hr_holidays.py:216
#: code:addons/hr_holidays_usability/hr_holidays.py:222
#: code:addons/hr_holidays_usability/hr_holidays.py:228
#: code:addons/hr_holidays_usability/hr_holidays.py:237
#: code:addons/hr_holidays_usability/hr_holidays.py:243
#: code:addons/hr_holidays_usability/hr_holidays.py:250
#: code:addons/hr_holidays_usability/hr_holidays.py:257
#: code:addons/hr_holidays_usability/hr_holidays.py:263
#: code:addons/hr_holidays_usability/hr_holidays.py:269
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:71
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:75
#: code:addons/hr_holidays_usability/wizard/hr_holidays_post.py:84
#, python-format
msgid "Error:"
msgstr "Erreur :"
@@ -188,6 +290,16 @@ msgstr "Par exemple, si vous partez en congé pendant une semaine calendaire, le
msgid "For example, if you leave one full calendar week, the first day of vacation is Monday Morning"
msgstr "Par exemple, si vous partez en congé pendant une semaine calendaire, le premier jour de congé est le lundi matin"
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
msgid "Get Holiday Requests"
msgstr "Obtenir les congés"
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
msgid "Group By"
msgstr "Grouper par"
#. module: hr_holidays_usability
#: selection:hr.holidays.status,vacation_compute_method:0
msgid "Jours ouvrables"
@@ -209,78 +321,215 @@ msgid "Leave"
msgstr "Congé"
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
#: field:hr.holidays.post,holidays_to_post_ids:0
msgid "Leave Requests to Post"
msgstr "Congés à comptabiliser"
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
#: field:hr.holidays.employee.counter,holiday_status_id:0
#: field:hr.holidays.mass.allocation,holiday_status_id:0
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_status
msgid "Leave Type"
msgstr "Type de congé"
#. module: hr_holidays_usability
#: view:hr.employee:0
#: view:res.company:0
msgid "Leaves"
msgstr "Congés"
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.resource_calendar_leaves_cal_first_action
#: model:ir.ui.menu,name:hr_holidays_usability.resource_calendar_leaves_cal_first_menu
msgid "Leaves Calendar"
msgstr "Calendrier des absences"
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,leaves_validated_posted:0
msgid "Leaves Posted"
msgstr "Congés comptabilisés"
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.hr_holidays_mass_allocation_action
#: model:ir.ui.menu,name:hr_holidays_usability.hr_holidays_mass_allocation_menu
msgid "Mass Allocation"
msgstr "Attribution en masse"
#. module: hr_holidays_usability
#: view:hr.holidays.mass.allocation:0
msgid "Mass Allocation of Holidays"
msgstr "Attribution de congés en masse"
#. module: hr_holidays_usability
#: selection:hr.holidays,vacation_time_from:0
msgid "Morning"
msgstr "Matin"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/wizard/hr_holidays_post.py:85
#, python-format
msgid "No leave request to post."
msgstr "Aucun congé à comptabiliser."
#. module: hr_holidays_usability
#: selection:hr.holidays,vacation_time_from:0
#: selection:hr.holidays,vacation_time_to:0
msgid "Noon"
msgstr "Midi"
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,number_of_days:0
msgid "Number of Days"
msgstr "Nombre de jours"
#. module: hr_holidays_usability
#: field:hr.holidays,number_of_days_remove:0
msgid "Number of Days of Vacation"
msgstr "Nombre de jours de congé"
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
msgid "Post"
msgstr "Comptabiliser"
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.hr_holidays_post_action
#: model:ir.ui.menu,name:hr_holidays_usability.hr_holidays_post_menu
msgid "Post Leave Requests"
msgstr "Comptabiliser les congés"
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
msgid "Post Leaves"
msgstr "Comptabiliser les congés"
#. module: hr_holidays_usability
#: field:hr.holidays,posted_date:0
msgid "Posted Date"
msgstr "Date de comptabilisation"
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,leaves_remaining_posted:0
msgid "Posted Remaining Leaves"
msgstr "Solde de congés comptabilisés"
#. module: hr_holidays_usability
#: field:hr.holidays.post,before_date:0
msgid "Select Leave Requests That Ended Before"
msgstr "Sélectionner les congés pris avant le"
#. module: hr_holidays_usability
#: field:hr.holidays,vacation_time_from:0
msgid "Start of Vacation"
msgstr "Début du congé"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:197
#: field:hr.holidays.post,state:0
msgid "State"
msgstr "State"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:238
#, python-format
msgid "The first day cannot be after the last day !"
msgstr "Le premier jour de congé ne peut pas être postérieur au dernier jour de congé !"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:223
#: code:addons/hr_holidays_usability/hr_holidays.py:264
#, python-format
msgid "The first day of vacation cannot be a bank holiday !"
msgstr "Le premier jour de congé ne peut pas être un jour férié !"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:210
#: code:addons/hr_holidays_usability/hr_holidays.py:251
#, python-format
msgid "The first day of vacation cannot be a saturday or sunday !"
msgstr "Le premier jour de congé ne peut pas être un Samedi ou un Dimanche !"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:217
#: code:addons/hr_holidays_usability/hr_holidays.py:258
#, python-format
msgid "The last day of Vacation cannot be a saturday or sunday !"
msgstr "Le dernier jour de congé ne peut pas être un Samedi ou un Dimanche !"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:229
#: code:addons/hr_holidays_usability/hr_holidays.py:270
#, python-format
msgid "The last day of vacation cannot be a bank holiday !"
msgstr "Le dernier jour de congé ne peut pas être un jour férié !"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:203
#: sql_constraint:hr.holidays.mass.allocation:0
msgid "The number of days must be positive"
msgstr "Le nombre de jours doit être positif"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:244
#, python-format
msgid "The start of vacation is exactly the same as the end !"
msgstr "Le début du congé est égal à la fin du congé !"
#. module: hr_holidays_usability
#: help:hr.holidays.post,before_date:0
msgid "The wizard will select the validated holidays that ended before that date (including holidays that ended on that date)."
msgstr "L'assistant sélectionnera les congés validés qui se sont terminés avant cette date ou à cette date."
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:347
#, python-format
msgid "There are not enough %s allocated for employee %s (requesting %s days but only %s days left)."
msgstr "Il n'y a pas assez de %s attribués à l'employé %s (demande de %s jours mais il ne reste que %s jours)."
#. module: hr_holidays_usability
#: field:hr.holidays,total_allocated_leaves:0
msgid "Total Allocated Leaves"
msgstr "Total des congés attribués"
#. module: hr_holidays_usability
#: view:hr.holidays:0
msgid "Total Days of Vacation"
msgstr "Total des congés pris"
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
msgid "Total Posted Remaining Leaves"
msgstr "Total du solde de congés comptabilisés"
#. module: hr_holidays_usability
#: field:hr.holidays.status,vacation_compute_method:0
msgid "Vacation Compute Method"
msgstr "Méthode de calcul des jours de congé"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:346
#, python-format
msgid "Warning!"
msgstr "Warning!"
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_mass_allocation
msgid "Wizard for mass allocation of holidays"
msgstr "Assistant pour l'attribution de congés en masse"
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_post
msgid "Wizard for post holidays"
msgstr "Assistant pour la comptabilisation des congés"
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:76
#, python-format
msgid "You must select at least one employee."
msgstr "Vous devez sélectionner au moins un employé."
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:72
#, python-format
msgid "You must set a value for the number of days."
msgstr "Vous devez entrer une valeur pour le nombre de jours."
#. module: hr_holidays_usability
#: constraint:hr.holidays:0
msgid "error msg in raise"

View File

@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-18 21:35+0000\n"
"PO-Revision-Date: 2015-05-18 21:35+0000\n"
"POT-Creation-Date: 2015-06-19 16:57+0000\n"
"PO-Revision-Date: 2015-06-19 16:57+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -47,7 +47,7 @@ msgid "\n"
"% endif\n"
"</li>\n"
"% endif\n"
"<li>Nombre de jours : ${object.number_of_days_temp or '0'}</li>\n"
"<li>Nombre de jours : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}</li>\n"
"<li>Type de congé : ${object.holiday_status_id.name or ''}</li>\n"
"<li>Description : ${object.name or ''}</li>\n"
"% if object.notes:\n"
@@ -71,11 +71,26 @@ msgid "\n"
""
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays:0
msgid " days"
msgstr ""
#. module: hr_holidays_usability
#: model:email.template,subject:hr_holidays_usability.email_template_hr_holidays
msgid "${ctx.get('dbname') and 'prod' not in ctx.get('dbname') and '[TEST]' or ''}[${object.type == 'remove' and 'Demande' or 'Attribution'} de congé ${ctx.get('wkf_tracker')}] ${object.name or ''} - ${object.employee_id.name or ''}"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,allocated_leaves:0
msgid "Allocated Leaves"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,limit:0
msgid "Allow to Override Limit"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.actions.server,name:hr_holidays_usability.ir_actions_server_hr_holidays_confirm_mail
msgid "Auto-email confirmed leave"
@@ -91,6 +106,95 @@ msgstr ""
msgid "Auto-email validated leave"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,auto_approve:0
msgid "Automatic Approval"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.mass.allocation:0
#: view:hr.holidays.post:0
msgid "Cancel"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_res_company
msgid "Companies"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays:0
msgid "Counter for this leave type"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.hr_holidays_employee_counter_action
#: model:ir.ui.menu,name:hr_holidays_usability.hr_holidays_employee_counter_menu
msgid "Counters"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_employee_counter
msgid "Counters for holidays of employees"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.mass.allocation:0
msgid "Create Allocations"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,current_leaves_taken:0
msgid "Current Leaves Taken"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,leaves_validated_current:0
msgid "Current Leaves Validated"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,current_remaining_leaves:0
#: field:hr.holidays.employee.counter,leaves_remaining_current:0
msgid "Current Remaining Leaves"
msgstr ""
#. module: hr_holidays_usability
#: field:res.company,mass_allocation_default_holiday_status_id:0
msgid "Default Leave Type for Mass Allocation"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,name:0
msgid "Description"
msgstr ""
#. module: hr_holidays_usability
#: selection:hr.holidays.post,state:0
msgid "Done"
msgstr ""
#. module: hr_holidays_usability
#: selection:hr.holidays.post,state:0
msgid "Draft"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
#: field:hr.holidays.employee.counter,employee_id:0
msgid "Employee"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
msgid "Employee Holidays Counters"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,employee_ids:0
msgid "Employees"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,vacation_time_to:0
msgid "End of Vacation"
@@ -107,12 +211,15 @@ msgid "Enter the last day of vacation. For example, if you leave one full calend
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:196
#: code:addons/hr_holidays_usability/hr_holidays.py:202
#: code:addons/hr_holidays_usability/hr_holidays.py:209
#: code:addons/hr_holidays_usability/hr_holidays.py:216
#: code:addons/hr_holidays_usability/hr_holidays.py:222
#: code:addons/hr_holidays_usability/hr_holidays.py:228
#: code:addons/hr_holidays_usability/hr_holidays.py:237
#: code:addons/hr_holidays_usability/hr_holidays.py:243
#: code:addons/hr_holidays_usability/hr_holidays.py:250
#: code:addons/hr_holidays_usability/hr_holidays.py:257
#: code:addons/hr_holidays_usability/hr_holidays.py:263
#: code:addons/hr_holidays_usability/hr_holidays.py:269
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:71
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:75
#: code:addons/hr_holidays_usability/wizard/hr_holidays_post.py:84
#, python-format
msgid "Error:"
msgstr ""
@@ -137,6 +244,16 @@ msgstr ""
msgid "For example, if you leave one full calendar week, the first day of vacation is Monday Morning"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
msgid "Get Holiday Requests"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
msgid "Group By"
msgstr ""
#. module: hr_holidays_usability
#: selection:hr.holidays.status,vacation_compute_method:0
msgid "Jours ouvrables"
@@ -158,78 +275,215 @@ msgid "Leave"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
#: field:hr.holidays.post,holidays_to_post_ids:0
msgid "Leave Requests to Post"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
#: field:hr.holidays.employee.counter,holiday_status_id:0
#: field:hr.holidays.mass.allocation,holiday_status_id:0
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_status
msgid "Leave Type"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.employee:0
#: view:res.company:0
msgid "Leaves"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.resource_calendar_leaves_cal_first_action
#: model:ir.ui.menu,name:hr_holidays_usability.resource_calendar_leaves_cal_first_menu
msgid "Leaves Calendar"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,leaves_validated_posted:0
msgid "Leaves Posted"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.hr_holidays_mass_allocation_action
#: model:ir.ui.menu,name:hr_holidays_usability.hr_holidays_mass_allocation_menu
msgid "Mass Allocation"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.mass.allocation:0
msgid "Mass Allocation of Holidays"
msgstr ""
#. module: hr_holidays_usability
#: selection:hr.holidays,vacation_time_from:0
msgid "Morning"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/wizard/hr_holidays_post.py:85
#, python-format
msgid "No leave request to post."
msgstr ""
#. module: hr_holidays_usability
#: selection:hr.holidays,vacation_time_from:0
#: selection:hr.holidays,vacation_time_to:0
msgid "Noon"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.mass.allocation,number_of_days:0
msgid "Number of Days"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,number_of_days_remove:0
msgid "Number of Days of Vacation"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
msgid "Post"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.actions.act_window,name:hr_holidays_usability.hr_holidays_post_action
#: model:ir.ui.menu,name:hr_holidays_usability.hr_holidays_post_menu
msgid "Post Leave Requests"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.post:0
msgid "Post Leaves"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,posted_date:0
msgid "Posted Date"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.employee.counter,leaves_remaining_posted:0
msgid "Posted Remaining Leaves"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.post,before_date:0
msgid "Select Leave Requests That Ended Before"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,vacation_time_from:0
msgid "Start of Vacation"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:197
#: field:hr.holidays.post,state:0
msgid "State"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:238
#, python-format
msgid "The first day cannot be after the last day !"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:223
#: code:addons/hr_holidays_usability/hr_holidays.py:264
#, python-format
msgid "The first day of vacation cannot be a bank holiday !"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:210
#: code:addons/hr_holidays_usability/hr_holidays.py:251
#, python-format
msgid "The first day of vacation cannot be a saturday or sunday !"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:217
#: code:addons/hr_holidays_usability/hr_holidays.py:258
#, python-format
msgid "The last day of Vacation cannot be a saturday or sunday !"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:229
#: code:addons/hr_holidays_usability/hr_holidays.py:270
#, python-format
msgid "The last day of vacation cannot be a bank holiday !"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:203
#: sql_constraint:hr.holidays.mass.allocation:0
msgid "The number of days must be positive"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:244
#, python-format
msgid "The start of vacation is exactly the same as the end !"
msgstr ""
#. module: hr_holidays_usability
#: help:hr.holidays.post,before_date:0
msgid "The wizard will select the validated holidays that ended before that date (including holidays that ended on that date)."
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:347
#, python-format
msgid "There are not enough %s allocated for employee %s (requesting %s days but only %s days left)."
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays,total_allocated_leaves:0
msgid "Total Allocated Leaves"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays:0
msgid "Total Days of Vacation"
msgstr ""
#. module: hr_holidays_usability
#: view:hr.holidays.employee.counter:0
msgid "Total Posted Remaining Leaves"
msgstr ""
#. module: hr_holidays_usability
#: field:hr.holidays.status,vacation_compute_method:0
msgid "Vacation Compute Method"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/hr_holidays.py:346
#, python-format
msgid "Warning!"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_mass_allocation
msgid "Wizard for mass allocation of holidays"
msgstr ""
#. module: hr_holidays_usability
#: model:ir.model,name:hr_holidays_usability.model_hr_holidays_post
msgid "Wizard for post holidays"
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:76
#, python-format
msgid "You must select at least one employee."
msgstr ""
#. module: hr_holidays_usability
#: code:addons/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py:72
#, python-format
msgid "You must set a value for the number of days."
msgstr ""
#. module: hr_holidays_usability
#: constraint:hr.holidays:0
msgid "error msg in raise"

View File

@@ -0,0 +1,2 @@
# -*- encoding: utf-8 -*-
from . import hr_holidays_employee_counter

View File

@@ -0,0 +1,83 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import fields, models, tools
class HrHolidaysEmployeeCounter(models.Model):
_name = 'hr.holidays.employee.counter'
_description = 'Counters for holidays of employees'
_auto = False
_rec_name = 'employee_id'
_order = 'employee_id'
employee_id = fields.Many2one('hr.employee', string="Employee")
holiday_status_id = fields.Many2one(
"hr.holidays.status", string="Leave Type")
leaves_validated_current = fields.Float(string='Current Leaves Validated')
leaves_validated_posted = fields.Float(string='Leaves Posted')
leaves_remaining_current = fields.Float(string='Current Remaining Leaves')
leaves_remaining_posted = fields.Float(string='Posted Remaining Leaves')
allocated_leaves = fields.Float(string='Allocated Leaves')
def init(self, cr):
tools.drop_view_if_exists(cr, 'hr_holidays_employee_counter')
cr.execute("""
CREATE or REPLACE view hr_holidays_employee_counter AS (
SELECT
min(hh.id) AS id,
hh.employee_id AS employee_id,
hh.holiday_status_id AS holiday_status_id,
sum(
CASE WHEN hh.type='remove'
THEN hh.number_of_days * -1
ELSE 0
END) AS leaves_validated_current,
sum(
CASE WHEN hh.type='remove'
AND hh.posted_date IS NOT null
THEN hh.number_of_days * -1
ELSE 0
END) AS leaves_validated_posted,
sum(hh.number_of_days) AS leaves_remaining_current,
sum(
CASE WHEN (
hh.type='remove' AND hh.posted_date IS NOT null)
OR hh.type='add'
THEN hh.number_of_days
ELSE 0
END) as leaves_remaining_posted,
sum(
CASE WHEN hh.type = 'add'
THEN hh.number_of_days
ELSE 0
END) AS allocated_leaves
FROM
hr_holidays hh
JOIN hr_holidays_status hhs
ON (hhs.id=hh.holiday_status_id)
WHERE
hh.state='validate' AND
hhs.limit=False
GROUP BY hh.employee_id, hh.holiday_status_id
)
""")

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="hr_holidays_employee_counter_tree" model="ir.ui.view">
<field name="name">hr.holidays.employee.counter.tree</field>
<field name="model">hr.holidays.employee.counter</field>
<field name="arch" type="xml">
<tree string="Employee Holidays Counters">
<field name="employee_id"
invisible="not context.get('hr_holidays_employee_counter_tree_main_view')"/>
<field name="holiday_status_id"/>
<field name="allocated_leaves"/>
<field name="leaves_validated_current"/>
<field name="leaves_validated_posted"/>
<field name="leaves_remaining_current"/>
<field name="leaves_remaining_posted"
sum="Total Posted Remaining Leaves"/>
</tree>
</field>
</record>
<record id="hr_holidays_employee_counter_search" model="ir.ui.view">
<field name="name">hr.holidays.employee.counter.search</field>
<field name="model">hr.holidays.employee.counter</field>
<field name="arch" type="xml">
<search>
<field name="employee_id"/>
<group string="Group By" name="groupby">
<filter name="employee_groupby" string="Employee" context="{'group_by': 'employee_id'}"/>
<filter name="holiday_status_groupby" string="Leave Type"
context="{'group_by': 'holiday_status_id'}"/>
</group>
</search>
</field>
</record>
<record id="hr_holidays_employee_counter_action" model="ir.actions.act_window">
<field name="name">Counters</field>
<field name="res_model">hr.holidays.employee.counter</field>
<field name="view_mode">tree</field>
<field name="context">{'hr_holidays_employee_counter_tree_main_view': 1}</field>
</record>
<menuitem id="hr_holidays_employee_counter_menu"
action="hr_holidays_employee_counter_action"
parent="hr_holidays.menu_open_ask_holidays"/>
</data>
</openerp>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_company_form" model="ir.ui.view">
<field name="name">hr_holidays_usability.res.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<group name="account_grp" position="after">
<group string="Leaves" name="holidays">
<field name="mass_allocation_default_holiday_status_id"/>
</group>
</group>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="hr_holidays_counter_personal_rule" model="ir.rule">
<field name="name">Personal Holiday Counters</field>
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
<field name="domain_force">['|',('employee_id.user_id','=',user.id),('employee_id.user_id','=',False)]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="hr_holidays_counter_see_all" model="ir.rule">
<field name="name">All Holiday Counters</field>
<field name="model_id" ref="model_hr_holidays_employee_counter"/>
<field name="domain_force">[(1,'=',1)]</field>
<field name="groups" eval="[(4, ref('base.group_hr_user'))]"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_hr_holidays_employee_counter,Full access on hr.holidays.employee.counter,model_hr_holidays_employee_counter,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_hr_holidays_employee_counter Full access on hr.holidays.employee.counter model_hr_holidays_employee_counter base.group_user 1 1 1 1

View File

@@ -0,0 +1,3 @@
# -*- encoding: utf-8 -*-
from . import hr_holidays_mass_allocation
from . import hr_holidays_post

View File

@@ -0,0 +1,89 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, workflow, _
from openerp.exceptions import Warning
class HrHolidaysMassAllocation(models.TransientModel):
_name = 'hr.holidays.mass.allocation'
_description = 'Wizard for mass allocation of holidays'
def _get_all_employees(self):
return self.pool['hr.employee'].search([])
def _get_default_holiday_status(self):
res = self._user.company_id.\
mass_allocation_default_holiday_status_id or False
return res
number_of_days = fields.Float(
string='Number of Days', required=True, default=2.08)
holiday_status_id = fields.Many2one(
'hr.holidays.status', string='Leave Type', required=True,
default=_get_default_holiday_status)
employee_ids = fields.Many2many(
'hr.employee', string='Employees', default=_get_all_employees)
auto_approve = fields.Boolean(
string='Automatic Approval', default=True)
# size=64 because the name field of hr.holidays is size=64
name = fields.Char('Description', size=64)
_sql_constraints = [(
'number_of_days_positive',
'CHECK (number_of_days > 0)',
'The number of days must be positive',
)]
@api.multi
def run(self):
self.ensure_one()
if not self.number_of_days:
raise Warning(
_('You must set a value for the number of days.'))
if not self.employee_ids:
raise Warning(
_('You must select at least one employee.'))
alloc_hol_ids = []
hho = self.env['hr.holidays']
auto_approve = self.auto_approve
for employee in self.employee_ids:
hol = hho.create({
'name': self.name,
'number_of_days_temp': self.number_of_days,
'employee_id': employee.id,
'type': 'add',
'holiday_type': 'employee',
'holiday_status_id': self.holiday_status_id.id,
})
if auto_approve:
workflow.trg_validate(
self._uid, 'hr.holidays', hol.id, 'validate', self._cr)
alloc_hol_ids.append(hol.id)
action = self.env['ir.actions.act_window'].for_xml_id(
'hr_holidays', 'open_allocation_holidays')
action.update({
'target': 'current',
'domain': [('id', 'in', alloc_hol_ids)],
'nodestroy': True,
})
return action

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="hr_holidays_mass_allocation_form" model="ir.ui.view">
<field name="name">hr_holidays_mass_allocation_form</field>
<field name="model">hr.holidays.mass.allocation</field>
<field name="arch" type="xml">
<form string="Mass Allocation of Holidays" version="7.0">
<group name="main">
<field name="name"/>
<field name="holiday_status_id"/>
<field name="employee_ids" widget="many2many_tags"/>
<field name="number_of_days"/>
<field name="auto_approve"/>
</group>
<footer>
<button name="run" type="object" string="Create Allocations"
class="oe_highlight"/>
<button special="cancel" string="Cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>
<record id="hr_holidays_mass_allocation_action" model="ir.actions.act_window">
<field name="name">Mass Allocation</field>
<field name="res_model">hr.holidays.mass.allocation</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem id="hr_holidays_mass_allocation_menu"
action="hr_holidays_mass_allocation_action"
parent="hr_holidays.menu_open_ask_holidays"
groups="base.group_hr_user"/>
</data>
</openerp>

View File

@@ -0,0 +1,86 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Holidays Usability module for Odoo
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, _
from openerp.exceptions import Warning
class HrHolidaysPost(models.TransientModel):
_name = 'hr.holidays.post'
_description = 'Wizard for post holidays'
before_date = fields.Date(
string='Select Leave Requests That Ended Before', required=True,
default=fields.Date.context_today,
help="The wizard will select the validated holidays "
"that ended before that date (including holidays that "
"ended on that date).")
holidays_to_post_ids = fields.Many2many(
'hr.holidays', string='Leave Requests to Post',
domain=[
('type', '=', 'remove'),
('holiday_type', '=', 'employee'),
('state', '=', 'validate'),
('posted_date', '=', False),
])
state = fields.Selection([
('draft', 'Draft'),
('done', 'Done'),
], string='State', readonly=True, default='draft')
@api.multi
def select_date(self):
self.ensure_one()
hols = self.pool['hr.holidays'].search([
('type', '=', 'remove'),
('holiday_type', '=', 'employee'),
('state', '=', 'validate'),
('posted_date', '=', False),
('vacation_date_to', '<=', self.before_date),
])
self.write({
'state': 'done',
'holidays_to_post_ids': [(6, 0, hols.ids)],
})
action = self.env['ir.actions.act_window'].for_xml_id(
'hr_holidays_usability', 'hr_holidays_post_action')
action['res_id'] = self.id
return action
@api.multi
def run(self):
self.ensure_one()
today = fields.Date.context_today(self)
if not self.holidays_to_post_ids:
raise Warning(
_('No leave request to post.'))
self.holidays_to_post_ids.write({'posted_date': today})
# On v8, return a graph view !
action = self.env['ir.actions.act_window'].for_xml_id(
'hr_holidays', 'open_ask_holidays')
action.update({
'target': 'current',
'domain': [('id', 'in', self.holidays_to_post_ids.ids)],
'nodestroy': True,
'context': {'group_by': ['employee_id', 'holiday_status_id']},
})
return action

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="hr_holidays_post_form" model="ir.ui.view">
<field name="name">hr_holidays_post_form</field>
<field name="model">hr.holidays.post</field>
<field name="arch" type="xml">
<form string="Post Leaves" version="7.0">
<group name="main" string="Leave Requests to Post">
<field name="state" invisible="1"/>
<field name="before_date" states="draft"/>
<field name="holidays_to_post_ids" nolabel="1"
context="{'tree_view_ref': 'hr_holidays.view_holiday'}"
states="done"/>
</group>
<footer>
<button name="select_date" type="object" string="Get Holiday Requests"
class="oe_highlight" states="draft"/>
<button name="run" type="object" string="Post"
class="oe_highlight" states="done"/>
<button special="cancel" string="Cancel" class="oe_link"/>
</footer>
</form>
</field>
</record>
<record id="hr_holidays_post_action" model="ir.actions.act_window">
<field name="name">Post Leave Requests</field>
<field name="res_model">hr.holidays.post</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem id="hr_holidays_post_menu"
action="hr_holidays_post_action"
parent="hr_holidays.menu_open_ask_holidays"
groups="base.group_hr_user"/>
</data>
</openerp>