diff --git a/addons/hr_holidays/models/hr_leave_type.py b/addons/hr_holidays/models/hr_leave_type.py index 3d26c56244b..758eb3b1719 100644 --- a/addons/hr_holidays/models/hr_leave_type.py +++ b/addons/hr_holidays/models/hr_leave_type.py @@ -352,17 +352,17 @@ class HolidaysType(models.Model): for future_allocation_interval in future_allocation_intervals._items: if future_allocation_interval[0].date() > search_date: continue + employee_quantity_available = future_allocation_interval[2].employee_id._get_work_days_data_batch( + future_allocation_interval[0], + future_allocation_interval[1], + compute_leaves=False, + domain=company_domain)[employee_id] for allocation in future_allocation_interval[2]: if not allocation.active or allocation.date_from > search_date: continue days_consumed = allocations_days_consumed[employee_id][holiday_status_id][allocation] if future_allocation_interval[1] != fields.datetime.combine(date, time.max) + timedelta(days=5*365): - # Compute the remaining number of days/hours in the allocation only if it has an end date - quantity_available = allocation.employee_id._get_work_days_data_batch( - future_allocation_interval[0], - future_allocation_interval[1], - compute_leaves=False, - domain=company_domain)[employee_id] + quantity_available = employee_quantity_available else: # If no end date to the allocation, consider the number of days remaining as infinite quantity_available = {'days': float('inf'), 'hours': float('inf')}