From 4edba45a5155f21c52d1479d3f711c727d93124f Mon Sep 17 00:00:00 2001 From: Dossogne Bertrand Date: Mon, 30 Oct 2023 15:02:25 +0100 Subject: [PATCH] [FIX] hr_holidays: fix accrual leaves display Before this commit, leaves linked to accrual allocations taken in the future would still be takin into account in the display, resulting in a warning if the leave excessed the amount that the employee currently had allocated. This leave removes any future leave to be taken into account if the leave type has any accrual allocation set for the employee. closes odoo/odoo#140888 Signed-off-by: Yannick Tivisse (yti) --- addons/hr_holidays/models/hr_employee.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/hr_holidays/models/hr_employee.py b/addons/hr_holidays/models/hr_employee.py index f4c7469a82c..d19bfe747ca 100644 --- a/addons/hr_holidays/models/hr_employee.py +++ b/addons/hr_holidays/models/hr_employee.py @@ -494,6 +494,7 @@ class HrEmployee(models.Model): leave_type_data = allocations_leaves_consumed[employee][leave_type] for leave in leaves_per_employee_type[employee][leave_type].sorted('date_from'): leave_duration = leave[leave_duration_field] + skip_excess = False if leave_type.requires_allocation == 'yes': for allocation in sorted_leave_allocations: # We don't want to include future leaves linked to accruals into the total count of available leaves. @@ -501,6 +502,7 @@ class HrEmployee(models.Model): # to give a warning if the total exceeds what will be accrued. if allocation.allocation_type == 'accrual' and leave.date_from.date() > target_date: to_recheck_leaves_per_leave_type[employee][leave_type]['to_recheck_leaves'] |= leave + skip_excess = True continue interval_start = max( leave.date_from, @@ -530,7 +532,7 @@ class HrEmployee(models.Model): leave_duration -= allocated_time if not leave_duration: break - if round(leave_duration, 2) > 0: + if round(leave_duration, 2) > 0 and not skip_excess: to_recheck_leaves_per_leave_type[employee][leave_type]['excess_days'][leave.date_to.date()] = { 'amount': leave_duration, 'is_virtual': leave.state != 'validate',