From a77c6fee494dbef9ab63c7dbbca43240a1b5b3e8 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Tue, 5 Dec 2023 09:38:42 +0100 Subject: [PATCH] [FIX] hr_contract: unsual days of the correct company When we create public holidays, we can create global ones that will apply to all 'Working Hours' of the company. When you create such a public holiday, it is displayed as a an unusual day for all employees of all companies that have a contract. The issue comes from the the fact that we use a sudo to get the contract of the employees and then we call '_get_unusual_day' on the Working Hours of the contract in sudo. So when we catch the global ones (wihtout Working Hours) it takes them from all companies as we are in sudo and it won't apply the record rule. closes odoo/odoo#144981 X-original-commit: 349762e28461f795d4e8bd3110556b5a80f92d49 Signed-off-by: Pierre Masereel (pim) --- addons/hr_contract/models/hr_employee.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_contract/models/hr_employee.py b/addons/hr_contract/models/hr_employee.py index 0a2c61f99ea..ba1536f4e99 100644 --- a/addons/hr_contract/models/hr_employee.py +++ b/addons/hr_contract/models/hr_employee.py @@ -134,7 +134,7 @@ class Employee(models.Model): for contract in employee_contracts: tmp_date_from = max(date_from_date, contract.date_start) tmp_date_to = min(date_to_date, contract.date_end) if contract.date_end else date_to_date - unusual_days.update(contract.resource_calendar_id._get_unusual_days( + unusual_days.update(contract.resource_calendar_id.sudo(False)._get_unusual_days( datetime.combine(fields.Date.from_string(tmp_date_from), time.min).replace(tzinfo=UTC), datetime.combine(fields.Date.from_string(tmp_date_to), time.max).replace(tzinfo=UTC) ))