From 41cc810d6b8ea7edddcc12ec7c6dae79c296b3dd Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 30 May 2023 12:59:21 +0000 Subject: [PATCH] [FIX] hr_holidays: public holidays affect other companies Issue: ------ In a multi-company context, the creation of a public holiday in one company will affect leaves in other companies. We cancel leaves that have the same time slot as the public holiday, regardless of the company. Solution: --------- Take account of the company in which the public holiday is created and compare it with the company of the employee who has leave. opw-3339973 closes odoo/odoo#123040 X-original-commit: 2d2d3388df7ffe0243d13d5b922b5ba6776a434d Signed-off-by: Kevin Baptiste --- addons/hr_holidays/models/resource.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/hr_holidays/models/resource.py b/addons/hr_holidays/models/resource.py index 5558bdc4e52..4ce33ccb214 100644 --- a/addons/hr_holidays/models/resource.py +++ b/addons/hr_holidays/models/resource.py @@ -36,6 +36,7 @@ class CalendarLeaves(models.Model): domain = [] for date in time_domain_dict: domain = expression.OR([domain, [ + ('employee_company_id', '=', date['company_id']), ('date_to', '>', date['date_from']), ('date_from', '<', date['date_to'])] ]) @@ -43,6 +44,7 @@ class CalendarLeaves(models.Model): def _get_time_domain_dict(self): return [{ + 'company_id' : record.company_id.id, 'date_from' : record.date_from, 'date_to' : record.date_to } for record in self if not record.resource_id]