From 96bd3e4dc9732cb4a6a2d699b5bde3046a84b921 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Mon, 23 Aug 2021 11:56:07 +0000 Subject: [PATCH] [FIX] hr_timesheet: fix traceback in portal view Opening the task portal view while having the timesheet encoding in days and having no timesheets linked to the viewed task would cause a traceback. This was caused by an index out of range exception. The function called has been changed to a `api.model` function instead and all calls have been changed to be compliant with that change. Closes: odoo/odoo#75452 Task ID: 2630244 Signed-off-by: Yannick Tivisse (yti) --- addons/hr_timesheet/models/hr_timesheet.py | 1 + addons/hr_timesheet/models/project.py | 1 + .../views/hr_timesheet_portal_templates.xml | 10 +++++----- addons/hr_timesheet/views/project_portal_templates.xml | 4 ++-- .../views/sale_timesheet_portal_templates.xml | 8 ++++---- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index a4b29d6282c..cbe9140b59a 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -238,6 +238,7 @@ class AccountAnalyticLine(models.Model): company_uom = self.env.company.timesheet_encode_uom_id return company_uom == self.env.ref('uom.product_uom_day') + @api.model def _convert_hours_to_days(self, time): uom_hour = self.env.ref('uom.product_uom_hour') uom_day = self.env.ref('uom.product_uom_day') diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index f68b5878d44..d7e4d41b4c9 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -325,6 +325,7 @@ class Task(models.Model): warning_msg, self.env.ref('hr_timesheet.timesheet_action_task').id, _('See timesheet entries'), {'active_ids': tasks_with_timesheets.ids}) + @api.model def _convert_hours_to_days(self, time): uom_hour = self.env.ref('uom.product_uom_hour') uom_day = self.env.ref('uom.product_uom_day') diff --git a/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml b/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml index 4385bbddd6a..dded6604b3e 100644 --- a/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml +++ b/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml @@ -45,7 +45,7 @@ - Total: + Total: Total: @@ -59,7 +59,7 @@ - Total: + Total: Total: @@ -73,7 +73,7 @@ - Total: + Total: Total: @@ -87,7 +87,7 @@ - Total: + Total: Total: @@ -98,7 +98,7 @@
- Total: + Total: Total: diff --git a/addons/hr_timesheet/views/project_portal_templates.xml b/addons/hr_timesheet/views/project_portal_templates.xml index a4626d1933a..8c9dd50f4e2 100644 --- a/addons/hr_timesheet/views/project_portal_templates.xml +++ b/addons/hr_timesheet/views/project_portal_templates.xml @@ -18,8 +18,8 @@ diff --git a/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml b/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml index b494ada7c29..ffc82fdacfa 100644 --- a/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml +++ b/addons/sale_timesheet/views/sale_timesheet_portal_templates.xml @@ -35,7 +35,7 @@ - Total: + Total: Total: @@ -52,7 +52,7 @@ - Total: + Total: Total: @@ -60,7 +60,7 @@ - + Timesheets for Invoice: @@ -69,7 +69,7 @@ - Total: + Total: Total: