From 55c77ae7d9dbd09a1ac532d0de0ea5bf7ea2fcda Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Mon, 11 Mar 2024 10:19:57 +0100 Subject: [PATCH] [FIX] hr_holidays: redirect to allocation record in report Steps to reproduce: ------------------- - go to time-off analysis (by type); - group by "Requet Type" and use list view; - click on an allocation; Issue: ------ We don't have the record for this allocation. Cause: ------ Commit [^1] removes the `allocation_id` field, so it is no longer possible to retrieve a record from the `hr.leave.allocation` model. Solution: --------- Place the allocation id in the `leave_id` field and use the `leave_type` field to determine the model (`hr.leave` or `hr.leave.allocation`). opw-3748884 [^1]: a1949ca541d760462add25995f139d1fb59f27d8 closes odoo/odoo#157204 Signed-off-by: Sofie Gvaladze (sgv) --- addons/hr_holidays/report/hr_leave_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_holidays/report/hr_leave_report.py b/addons/hr_holidays/report/hr_leave_report.py index 07aa2ab271c..e4b2cfbc879 100644 --- a/addons/hr_holidays/report/hr_leave_report.py +++ b/addons/hr_holidays/report/hr_leave_report.py @@ -52,7 +52,7 @@ class LeaveReport(models.Model): leaves.holiday_type as holiday_type, leaves.date_from as date_from, leaves.date_to as date_to, leaves.company_id from (select - null as leave_id, + allocation.id as leave_id, allocation.employee_id as employee_id, allocation.private_name as name, allocation.number_of_days as number_of_days, @@ -97,5 +97,5 @@ class LeaveReport(models.Model): 'type': 'ir.actions.act_window', 'view_mode': 'form', 'res_id': self.leave_id.id, - 'res_model': 'hr.leave', + 'res_model': 'hr.leave' if self.leave_type == 'request' else 'hr.leave.allocation', }