From 1ff2416435c1aa98d1a37ba1c80baaaffb7be63f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 23 Jun 2015 16:29:47 +0200 Subject: [PATCH] Up-port new stuff from hr_holidays_usability from 7.0 to 8.0 --- hr_holidays_usability/__init__.py | 2 + hr_holidays_usability/__openerp__.py | 7 + hr_holidays_usability/hr_employee_view.xml | 22 ++ hr_holidays_usability/hr_holidays.py | 53 +++- hr_holidays_usability/hr_holidays_mail.xml | 2 +- hr_holidays_usability/hr_holidays_view.xml | 28 +- hr_holidays_usability/i18n/fr.po | 281 ++++++++++++++++- .../i18n/hr_holidays_usability.pot | 284 +++++++++++++++++- hr_holidays_usability/report/__init__.py | 2 + .../report/hr_holidays_employee_counter.py | 83 +++++ .../hr_holidays_employee_counter_view.xml | 51 ++++ hr_holidays_usability/res_company_view.xml | 24 ++ .../security/holiday_security.xml | 20 ++ .../security/ir.model.access.csv | 2 + hr_holidays_usability/wizard/__init__.py | 3 + .../wizard/hr_holidays_mass_allocation.py | 89 ++++++ .../hr_holidays_mass_allocation_view.xml | 45 +++ .../wizard/hr_holidays_post.py | 86 ++++++ .../wizard/hr_holidays_post_view.xml | 47 +++ 19 files changed, 1095 insertions(+), 36 deletions(-) create mode 100644 hr_holidays_usability/hr_employee_view.xml create mode 100644 hr_holidays_usability/report/__init__.py create mode 100644 hr_holidays_usability/report/hr_holidays_employee_counter.py create mode 100644 hr_holidays_usability/report/hr_holidays_employee_counter_view.xml create mode 100644 hr_holidays_usability/res_company_view.xml create mode 100644 hr_holidays_usability/security/holiday_security.xml create mode 100644 hr_holidays_usability/security/ir.model.access.csv create mode 100644 hr_holidays_usability/wizard/__init__.py create mode 100644 hr_holidays_usability/wizard/hr_holidays_mass_allocation.py create mode 100644 hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml create mode 100644 hr_holidays_usability/wizard/hr_holidays_post.py create mode 100644 hr_holidays_usability/wizard/hr_holidays_post_view.xml diff --git a/hr_holidays_usability/__init__.py b/hr_holidays_usability/__init__.py index dfa6080..0b8dc8c 100644 --- a/hr_holidays_usability/__init__.py +++ b/hr_holidays_usability/__init__.py @@ -21,3 +21,5 @@ ############################################################################## from . import hr_holidays +from . import wizard +from . import report diff --git a/hr_holidays_usability/__openerp__.py b/hr_holidays_usability/__openerp__.py index 73d60e0..1362a6e 100644 --- a/hr_holidays_usability/__openerp__.py +++ b/hr_holidays_usability/__openerp__.py @@ -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, } diff --git a/hr_holidays_usability/hr_employee_view.xml b/hr_holidays_usability/hr_employee_view.xml new file mode 100644 index 0000000..c0dd981 --- /dev/null +++ b/hr_holidays_usability/hr_employee_view.xml @@ -0,0 +1,22 @@ + + + + + + + hr_holidays_usability.hr.employee.form + hr.employee + + + + 1 + + + + + + diff --git a/hr_holidays_usability/hr_holidays.py b/hr_holidays_usability/hr_holidays.py index 3bec144..85ec30a 100644 --- a/hr_holidays_usability/hr_holidays.py +++ b/hr_holidays_usability/hr_holidays.py @@ -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') diff --git a/hr_holidays_usability/hr_holidays_mail.xml b/hr_holidays_usability/hr_holidays_mail.xml index 54f9e26..985a8ed 100644 --- a/hr_holidays_usability/hr_holidays_mail.xml +++ b/hr_holidays_usability/hr_holidays_mail.xml @@ -84,7 +84,7 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, force
  • Start date : ${object.vacation_date_from or ''} ${object.vacation_time_from or ''}
  • End date : ${object.vacation_date_to or ''} ${object.vacation_time_to or ''}
  • % endif -
  • Number of days : ${object.number_of_days or '0'}
  • +
  • Number of days : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}
  • Leave type : ${object.holiday_status_id.name or ''}
  • Description : ${object.name or ''}
  • % if object.notes: diff --git a/hr_holidays_usability/hr_holidays_view.xml b/hr_holidays_usability/hr_holidays_view.xml index 731cc02..c353716 100644 --- a/hr_holidays_usability/hr_holidays_view.xml +++ b/hr_holidays_usability/hr_holidays_view.xml @@ -38,6 +38,29 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> + + + + + + + + @@ -50,7 +73,7 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> 1 - + 1 @@ -69,6 +92,9 @@ hr_holidays.edit_holiday_new is used for both leaves and allocation --> 0 + + + diff --git a/hr_holidays_usability/i18n/fr.po b/hr_holidays_usability/i18n/fr.po index 9a2ce29..d970a1c 100644 --- a/hr_holidays_usability/i18n/fr.po +++ b/hr_holidays_usability/i18n/fr.po @@ -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" "\n" "% endif\n" -"
  • Nombre de jours : ${object.number_of_days_temp or '0'}
  • \n" +"
  • Nombre de jours : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}
  • \n" "
  • Type de congé : ${object.holiday_status_id.name or ''}
  • \n" "
  • Description : ${object.name or ''}
  • \n" "% if object.notes:\n" @@ -99,7 +99,7 @@ msgstr "\n" "% endif\n" "\n" "% endif\n" -"
  • Nombre de jours : ${object.number_of_days_temp or '0'}
  • \n" +"
  • Nombre de jours : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}
  • \n" "
  • Type de congé : ${object.holiday_status_id.name or ''}
  • \n" "
  • Description : ${object.name or ''}
  • \n" "% if object.notes:\n" @@ -122,11 +122,26 @@ msgstr "\n" "\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" diff --git a/hr_holidays_usability/i18n/hr_holidays_usability.pot b/hr_holidays_usability/i18n/hr_holidays_usability.pot index 3bc1937..1333184 100644 --- a/hr_holidays_usability/i18n/hr_holidays_usability.pot +++ b/hr_holidays_usability/i18n/hr_holidays_usability.pot @@ -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" "\n" "% endif\n" -"
  • Nombre de jours : ${object.number_of_days_temp or '0'}
  • \n" +"
  • Nombre de jours : ${object.number_of_days < 0 and object.number_of_days * -1 or object.number_of_days}
  • \n" "
  • Type de congé : ${object.holiday_status_id.name or ''}
  • \n" "
  • Description : ${object.name or ''}
  • \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" diff --git a/hr_holidays_usability/report/__init__.py b/hr_holidays_usability/report/__init__.py new file mode 100644 index 0000000..ac96859 --- /dev/null +++ b/hr_holidays_usability/report/__init__.py @@ -0,0 +1,2 @@ +# -*- encoding: utf-8 -*- +from . import hr_holidays_employee_counter diff --git a/hr_holidays_usability/report/hr_holidays_employee_counter.py b/hr_holidays_usability/report/hr_holidays_employee_counter.py new file mode 100644 index 0000000..be8c227 --- /dev/null +++ b/hr_holidays_usability/report/hr_holidays_employee_counter.py @@ -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 +# +# 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 . +# +############################################################################## + +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 + ) + """) diff --git a/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml b/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml new file mode 100644 index 0000000..84ab852 --- /dev/null +++ b/hr_holidays_usability/report/hr_holidays_employee_counter_view.xml @@ -0,0 +1,51 @@ + + + + + + hr.holidays.employee.counter.tree + hr.holidays.employee.counter + + + + + + + + + + + + + + + hr.holidays.employee.counter.search + hr.holidays.employee.counter + + + + + + + + + + + + + Counters + hr.holidays.employee.counter + tree + {'hr_holidays_employee_counter_tree_main_view': 1} + + + + + + + diff --git a/hr_holidays_usability/res_company_view.xml b/hr_holidays_usability/res_company_view.xml new file mode 100644 index 0000000..68f6ec1 --- /dev/null +++ b/hr_holidays_usability/res_company_view.xml @@ -0,0 +1,24 @@ + + + + + + + hr_holidays_usability.res.company.form + res.company + + + + + + + + + + + + diff --git a/hr_holidays_usability/security/holiday_security.xml b/hr_holidays_usability/security/holiday_security.xml new file mode 100644 index 0000000..1659ffa --- /dev/null +++ b/hr_holidays_usability/security/holiday_security.xml @@ -0,0 +1,20 @@ + + + + + + Personal Holiday Counters + + ['|',('employee_id.user_id','=',user.id),('employee_id.user_id','=',False)] + + + + + All Holiday Counters + + [(1,'=',1)] + + + + + diff --git a/hr_holidays_usability/security/ir.model.access.csv b/hr_holidays_usability/security/ir.model.access.csv new file mode 100644 index 0000000..26f7dac --- /dev/null +++ b/hr_holidays_usability/security/ir.model.access.csv @@ -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 diff --git a/hr_holidays_usability/wizard/__init__.py b/hr_holidays_usability/wizard/__init__.py new file mode 100644 index 0000000..07d448e --- /dev/null +++ b/hr_holidays_usability/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- encoding: utf-8 -*- +from . import hr_holidays_mass_allocation +from . import hr_holidays_post diff --git a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py new file mode 100644 index 0000000..227e063 --- /dev/null +++ b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py @@ -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 +# +# 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 . +# +############################################################################## + +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 diff --git a/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml b/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml new file mode 100644 index 0000000..b92af37 --- /dev/null +++ b/hr_holidays_usability/wizard/hr_holidays_mass_allocation_view.xml @@ -0,0 +1,45 @@ + + + + + + + + hr_holidays_mass_allocation_form + hr.holidays.mass.allocation + +
    + + + + + + + +
    +
    +
    +
    +
    + + + Mass Allocation + hr.holidays.mass.allocation + form + new + + + + +
    +
    diff --git a/hr_holidays_usability/wizard/hr_holidays_post.py b/hr_holidays_usability/wizard/hr_holidays_post.py new file mode 100644 index 0000000..952a4ac --- /dev/null +++ b/hr_holidays_usability/wizard/hr_holidays_post.py @@ -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 +# +# 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 . +# +############################################################################## + +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 diff --git a/hr_holidays_usability/wizard/hr_holidays_post_view.xml b/hr_holidays_usability/wizard/hr_holidays_post_view.xml new file mode 100644 index 0000000..eebfe24 --- /dev/null +++ b/hr_holidays_usability/wizard/hr_holidays_post_view.xml @@ -0,0 +1,47 @@ + + + + + + + + hr_holidays_post_form + hr.holidays.post + +
    + + + + + +
    +
    +
    +
    +
    + + + Post Leave Requests + hr.holidays.post + form + new + + + + +
    +