diff --git a/addons/hr_holidays/i18n/hr_holidays.pot b/addons/hr_holidays/i18n/hr_holidays.pot index 750e38af69f03414d9a559b3794add64efda6bc8..5a3882217ea8fa4b249f8037a156d4233ee2cbeb 100644 --- a/addons/hr_holidays/i18n/hr_holidays.pot +++ b/addons/hr_holidays/i18n/hr_holidays.pot @@ -4058,6 +4058,13 @@ msgid "" "You don't have the rights to apply second approval on a time off request" msgstr "" +#. module: hr_holidays +#: code:addons/hr_holidays/models/hr_leave.py:0 +#, python-format +msgid "" +"You must be %s\'s Manager to approve this leave" +msgstr "" + #. module: hr_holidays #: code:addons/hr_holidays/models/hr_leave.py:0 #, python-format diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index d2c7a78a8b300d9dac83958073d07aa6fed1f23c..278cc0b8b1ecaa3ee0ff51e9c1ccae1bd6f09937 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -1414,10 +1414,13 @@ class HolidaysRequest(models.Model): if holiday.employee_id == current_employee: raise UserError(_('Only a Time Off Manager can approve/refuse its own requests.')) - if (state == 'validate1' and val_type == 'both') or (state == 'validate' and val_type == 'manager') and holiday.holiday_type == 'employee': + if (state == 'validate1' and val_type == 'both') and holiday.holiday_type == 'employee': 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 (state == 'validate' and val_type == 'manager') and self.env.user != holiday.employee_id.leave_manager_id: + raise UserError(_('You must be %s\'s 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'))