From caefc5b04883c3aa6f4290012cb7eeaad6260c34 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Fri, 18 Feb 2022 09:05:24 +0000 Subject: [PATCH] [FIX] hr_holidays: fix invalid first level next call date Prior to this commit the next call date for the first level would not take the second level into account, as such it could be that the first level would be completely skipped instead of being prorated properly. TaskId-2768435 closes odoo/odoo#84899 X-original-commit: 791b801c7b96a94353031a06dd5da4eeb20ee08b Signed-off-by: Yannick Tivisse (yti) Signed-off-by: William Braeckman (wbr) --- addons/hr_holidays/models/hr_leave_allocation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index 20c44ae7a9e..4f568334646 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -411,6 +411,9 @@ class HolidaysAllocation(models.Model): continue allocation.lastcall = max(allocation.lastcall, first_level_start_date) allocation.nextcall = first_level._get_next_date(allocation.lastcall) + if len(level_ids) > 1: + second_level_start_date = allocation.date_from + get_timedelta(level_ids[1].start_count, level_ids[1].start_type) + allocation.nextcall = min(second_level_start_date - relativedelta(days=1), allocation.nextcall) allocation._message_log(body=first_allocation) days_added_per_level = defaultdict(lambda: 0) while allocation.nextcall <= today: