[FIX] hr_holidays: Add method to allow inheritance
closes odoo/odoo#70125 X-original-commit: 12ba83ce60c74a8dcfb773a2c21bbf31b681ab30 Related: odoo/enterprise#18044 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -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')))
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user