diff --git a/addons/hr_work_entry_contract/models/hr_contract.py b/addons/hr_work_entry_contract/models/hr_contract.py index 79cccb69037..7f85dcc826d 100644 --- a/addons/hr_work_entry_contract/models/hr_contract.py +++ b/addons/hr_work_entry_contract/models/hr_contract.py @@ -31,7 +31,10 @@ class HrContract(models.Model): def _get_more_vals_leave_interval(self, interval, leaves): return [] - def _get_interval_leave_work_entry_type(self, interval, leaves): + def _get_bypassing_work_entry_type(self): + return self.env['hr.work.entry.type'] + + def _get_interval_leave_work_entry_type(self, interval, leaves, bypassing): # returns the work entry time related to the leave that # includes the whole interval. # Overriden in hr_work_entry_contract_holiday to select the @@ -45,6 +48,7 @@ class HrContract(models.Model): def _get_contract_work_entries_values(self, date_start, date_stop): contract_vals = [] + bypassing_work_entry_type = self._get_bypassing_work_entry_type() for contract in self: employee = contract.employee_id calendar = contract.resource_calendar_id @@ -129,7 +133,7 @@ class HrContract(models.Model): # sql constraint error if interval[0] == interval[1]: # if start == stop continue - leave_entry_type = contract._get_interval_leave_work_entry_type(interval, leaves) + leave_entry_type = contract._get_interval_leave_work_entry_type(interval, leaves, bypassing_work_entry_type) interval_start = interval[0].astimezone(pytz.utc).replace(tzinfo=None) interval_stop = interval[1].astimezone(pytz.utc).replace(tzinfo=None) contract_vals += [dict([ diff --git a/addons/hr_work_entry_holidays/models/hr_contract.py b/addons/hr_work_entry_holidays/models/hr_contract.py index fd52f6b964f..3cbd6a66270 100644 --- a/addons/hr_work_entry_holidays/models/hr_contract.py +++ b/addons/hr_work_entry_holidays/models/hr_contract.py @@ -40,10 +40,7 @@ class HrContract(models.Model): result.append(('leave_id', leave[2].holiday_id.id)) return result - def _get_bypassing_work_entry_type(self): - return self.env['hr.work.entry.type'] - - def _get_interval_leave_work_entry_type(self, interval, leaves): + def _get_interval_leave_work_entry_type(self, interval, leaves, bypassing): # returns the work entry time related to the leave that # includes the whole interval. # Overriden in hr_work_entry_contract_holiday to select the @@ -56,9 +53,8 @@ class HrContract(models.Model): rc_leave = False # Example: In CP200: Long term sick > Public Holidays (which is global) - bypassing_work_entry_types = self._get_bypassing_work_entry_type() - if bypassing_work_entry_types: - bypassing_rc_leave = [l for l in including_holiday_rcleaves if l.holiday_id.holiday_status_id.work_entry_type_id in bypassing_work_entry_types] + if bypassing: + bypassing_rc_leave = [l for l in including_holiday_rcleaves if l.holiday_id.holiday_status_id.work_entry_type_id in bypassing] else: bypassing_rc_leave = []