From 2215e69daee051e794122a33839cb35c4ff032f1 Mon Sep 17 00:00:00 2001 From: Thibault Libioulle Date: Wed, 2 Jun 2021 07:40:37 +0000 Subject: [PATCH] [FIX] hr_timesheet: fix date issue in activity report Before this commit, the date taken into account to retrieve people activities in the project update description was the UTC date. The activities just recorded with the context_today date wasn't taken into account. Failing unit tests during nightly build (when date UTC < date GMT+2): - `TestProjectUpdateHrTimesheet.test_project_update_description_people` "AssertionError: 0 != 1 : The number of recorded timesheet activities is 1" - `TestProjectUpdateHrTimesheet.test_project_update_form_people` "AssertionError: False is not true : The description should contain 'People'" This commit fixes the issue using the context_today(self) date as a reference. Fixes PR : #68899 task-2393768 closes odoo/odoo#71585 Signed-off-by: LTU-Odoo --- addons/hr_timesheet/models/project_update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/hr_timesheet/models/project_update.py b/addons/hr_timesheet/models/project_update.py index 797556e1807..c679c6cd66c 100644 --- a/addons/hr_timesheet/models/project_update.py +++ b/addons/hr_timesheet/models/project_update.py @@ -28,10 +28,10 @@ class ProjectUpdate(models.Model): def _get_activities(self, project): if not self.user_has_groups('hr_timesheet.group_hr_timesheet_user'): return [] - today = fields.Datetime.today() + today = fields.Date.context_today(self) query = """ SELECT timesheet.employee_id as employee_id, - gs as period, + gs::date as period, sum(timesheet.unit_amount) as unit_amount, employee.name as name FROM project_project p @@ -40,8 +40,8 @@ class ProjectUpdate(models.Model): INNER JOIN hr_employee employee ON timesheet.employee_id = employee.id CROSS JOIN generate_series( - %(today)s::date - '180 days'::interval, - %(today)s::date, + %(today)s - '180 days'::interval, + %(today)s, '30 days'::interval ) gs WHERE p.id = %(project_id)s