diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index eb9936a4732..5a947105c57 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -989,9 +989,12 @@ class HolidaysRequest(models.Model): self.activity_update() return True + def _get_leaves_on_public_holiday(self): + return self.filtered(lambda l: l.employee_id and not l.number_of_days) + def action_validate(self): current_employee = self.env.user.employee_id - leaves = self.filtered(lambda l: l.employee_id and not l.number_of_days) + leaves = self._get_leaves_on_public_holiday() if leaves: raise ValidationError(_('The following employees are not supposed to work during that period:\n %s') % ','.join(leaves.mapped('employee_id.name'))) diff --git a/addons/hr_work_entry_holidays/models/hr_contract.py b/addons/hr_work_entry_holidays/models/hr_contract.py index 3cbd6a66270..8a22e117cfd 100644 --- a/addons/hr_work_entry_holidays/models/hr_contract.py +++ b/addons/hr_work_entry_holidays/models/hr_contract.py @@ -45,6 +45,9 @@ class HrContract(models.Model): # includes the whole interval. # Overriden in hr_work_entry_contract_holiday to select the # global time off first (eg: Public Holiday > Home Working) + if interval[2].work_entry_type_id in bypassing: + return interval[2].work_entry_type_id + interval_start = interval[0].astimezone(pytz.utc).replace(tzinfo=None) interval_stop = interval[1].astimezone(pytz.utc).replace(tzinfo=None) including_rcleaves = [l[2] for l in leaves if l[2] and interval_start >= l[2].date_from and interval_stop <= l[2].date_to] diff --git a/addons/hr_work_entry_holidays/models/hr_leave.py b/addons/hr_work_entry_holidays/models/hr_leave.py index 3e8721d12a2..b8ceef67556 100644 --- a/addons/hr_work_entry_holidays/models/hr_leave.py +++ b/addons/hr_work_entry_holidays/models/hr_leave.py @@ -161,6 +161,10 @@ class HrLeave(models.Model): with self.env['hr.work.entry']._error_checking(start=start, stop=stop): return super().action_confirm() + def _get_leaves_on_public_holiday(self): + return super()._get_leaves_on_public_holiday().filtered( + lambda l: l.holiday_status_id.work_entry_type_id.code not in ['LEAVE110', 'LEAVE280']) + def action_validate(self): super(HrLeave, self).action_validate() self.sudo()._cancel_work_entry_conflict() # delete preexisting conflicting work_entries