[FIX] hr_holidays: Compute hours based on employee

If allocation use the employee mode, the displayed hour must be based on the employee schedule not on the company schedule

Partial revert of https://github.com/odoo/odoo/pull/96419

opw-3201224

closes odoo/odoo#118485

X-original-commit: 62c489fb8523e4ca231ef90e514f6f06c1e3d5da
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Gaetan Vanden Bergh (gavb)
2023-04-13 17:57:47 +02:00
parent 63558ea976
commit 31b4fc06c4
@@ -209,10 +209,15 @@ class HolidaysAllocation(models.Model):
for allocation in self:
allocation.number_of_days_display = allocation.number_of_days
@api.depends('number_of_days', 'holiday_status_id')
@api.depends('number_of_days', 'holiday_status_id', 'employee_id', 'holiday_type')
def _compute_number_of_hours_display(self):
for allocation in self:
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)
allocation_calendar = allocation.holiday_status_id.company_id.resource_calendar_id
if allocation.holiday_type == 'employee':
allocation_calendar = allocation.employee_id.sudo().resource_calendar_id
allocation.number_of_hours_display = allocation.number_of_days * (allocation_calendar.hours_per_day or HOURS_PER_DAY)
@api.depends('number_of_hours_display', 'number_of_days_display')
def _compute_duration_display(self):