From 3bfcf83db7c3cffcbb23a7402574d3e3172f3749 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Wed, 20 Jul 2022 12:29:52 +0000 Subject: [PATCH] [IMP] hr_holiday: Ensure persistence of number_of_hours_display Purpose ======= Base the number_of_hours_display on the company calendar instead of the employee calendar to avoid modifying the informative allocated value in case of a working schedule change. closes odoo/odoo#96419 Signed-off-by: Yannick Tivisse (yti) --- addons/hr_holidays/models/hr_leave_allocation.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index cf43d0ac769..3fa1237f99c 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -205,15 +205,10 @@ class HolidaysAllocation(models.Model): for allocation in self: allocation.number_of_days_display = allocation.number_of_days - @api.depends('number_of_days', 'employee_id') + @api.depends('number_of_days', 'holiday_status_id') def _compute_number_of_hours_display(self): for allocation in self: - if allocation.parent_id and allocation.parent_id.type_request_unit == "hour": - allocation.number_of_hours_display = allocation.number_of_days * HOURS_PER_DAY - elif allocation.number_of_days: - allocation.number_of_hours_display = allocation.number_of_days * (allocation.employee_id.sudo().resource_id.calendar_id.hours_per_day or HOURS_PER_DAY) - else: - allocation.number_of_hours_display = 0.0 + allocation.number_of_hours_display = allocation.number_of_days * (allocation.holiday_status_id.company_id.resource_calendar_id.hours_per_day or HOURS_PER_DAY) @api.depends('number_of_hours_display', 'number_of_days_display') def _compute_duration_display(self):