From 52b0a0685165ec517da44abcdb488d997ad5872b Mon Sep 17 00:00:00 2001 From: "Xavier Bol (xbo)" Date: Tue, 26 Sep 2023 15:18:20 +0200 Subject: [PATCH] [IMP] hr_timesheet: unset the task_id when the project changed Before this commit, when the project of the timesheet changed, the task_id of the timesheet is not unset and so it could have some inconsistency. This commit ensures the task linked to the timesheet has the same project than the one set on the timesheet, otherwise the task_id is unset. part of task-2276015 task-3542388 Part-of: odoo/odoo#137820 --- addons/hr_timesheet/models/hr_timesheet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/hr_timesheet/models/hr_timesheet.py b/addons/hr_timesheet/models/hr_timesheet.py index 36cc647c536..0d0098038f1 100644 --- a/addons/hr_timesheet/models/hr_timesheet.py +++ b/addons/hr_timesheet/models/hr_timesheet.py @@ -104,7 +104,9 @@ class AccountAnalyticLine(models.Model): @api.depends('project_id') def _compute_task_id(self): - for line in self.filtered(lambda line: not line.project_id): + for line in self: + if line.project_id and line.project_id == line.task_id.project_id: + continue line.task_id = False @api.onchange('project_id')