From 5cdb8f51a356a547ef89c19946540df3dc08b04f Mon Sep 17 00:00:00 2001 From: Philippe Wauthy Date: Mon, 22 Nov 2021 09:33:11 +0000 Subject: [PATCH] [FIX] hr_holidays: fix time off with allocation of one day As an HR officer, when you create an allocation of one day for a user, you need to be able to put a time off on that person, following the allocation. But for the moment, we got an error saying there is no valid allocation on that day. If you create an allocation of 1 day, you need to be able to put a time off on that specific day without any error message. task-2696771 closes odoo/odoo#80196 X-original-commit: 60f691bbac660d47404b35242303288880f084f7 Signed-off-by: Kevin Baptiste --- addons/hr_holidays/models/hr_leave.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index 59ffa5044c2..9b1068e892c 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -364,9 +364,9 @@ class HolidaysRequest(models.Model): date_to = leave.date_to.replace(tzinfo=UTC).astimezone(timezone(leave.tz)).date() date_from = leave.date_from.replace(tzinfo=UTC).astimezone(timezone(leave.tz)).date() for allocation in allocations_dict[(leave.holiday_status_id.id, leave.employee_id.id)]: - date_to_check = allocation['date_to'] > date_to if allocation['date_to'] else False - date_from_check = allocation['date_to'] is False and allocation['date_from'] <= date_from - if (date_to_check or date_from_check): + date_to_check = allocation['date_to'] >= date_to if allocation['date_to'] else True + date_from_check = allocation['date_from'] <= date_from + if (date_to_check and date_from_check): found_allocation = allocation['id'] break leave.holiday_allocation_id = self.env['hr.leave.allocation'].browse(found_allocation) if found_allocation else False