[FIX] hr_holidays: HR leave only approvable by time off officer

Step to reproduce:
- Create a time off type T with approval 'time off officer'
- As user U create a time off request of type T
- Login as the manager of U (which should not be a time off
 officer)
- Approve the time off of U

Current Behaviour:
- Time off is approved

Behaviour after PR:
- Time off is not approved and an error is raised

opw-2753845

closes odoo/odoo#85622

X-original-commit: 8a0564369baf9de7797a58ab0cd5cae870b910cf
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Damhaut Florian (flda) <flda@odoo.com>
This commit is contained in:
Florian Damhaut
2022-03-02 07:20:51 +00:00
parent 0ab9cf3fa0
commit 268025dccc
2 changed files with 9 additions and 0 deletions
+6
View File
@@ -4072,6 +4072,12 @@ msgid ""
"You must be either %s's manager or time off manager to approve this time off"
msgstr ""
#. module: hr_holidays
#: code:addons/hr_holidays/models/hr_leave_allocation.py:0
msgid ""
"You must either be a Time off Officer or Time off Manager to approve this leave"
""
#. module: hr_holidays
#: model:ir.model.constraint,message:hr_holidays.constraint_hr_leave_accrual_level_added_value_greater_than_zero
msgid "You must give a rate greater than 0 in accrual plan levels."
+3
View File
@@ -1416,6 +1416,9 @@ class HolidaysRequest(models.Model):
if not is_officer and self.env.user != holiday.employee_id.leave_manager_id:
raise UserError(_('You must be either %s\'s manager or Time off Manager to approve this leave') % (holiday.employee_id.name))
if not is_officer and (state == 'validate' and val_type == 'hr') and holiday.holiday_type == 'employee':
raise UserError(_('You must either be a Time off Officer or Time off Manager to approve this leave'))
# ------------------------------------------------------------
# Activity methods
# ------------------------------------------------------------