From c2b28801ef130e846cf40aef0335d9186538ca8b Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 25 Feb 2021 15:24:26 +0100 Subject: [PATCH] [IMP] sale_timesheet: remove SO if the partner is not the same Before this commit, when the user creates a task in a project in which the partner is defined, the partner in the task is the one in the project. If the user changes the partner in the task, then the SO in this task should not be the one in the project since the partner is different. This commit removes the SO if the partner in the task is different than the one in the SO. task-2442683 closes #66181 --- addons/sale_timesheet/models/project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index 2ce0eddc3c4..0e8ac1b730b 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -269,7 +269,7 @@ class ProjectTask(models.Model): for task in self: task.analytic_account_active = task.analytic_account_active or task.analytic_account_id.active - @api.depends('sale_line_id', 'project_id', 'allow_billable') + @api.depends('sale_line_id', 'project_id', 'allow_billable', 'commercial_partner_id') def _compute_sale_order_id(self): for task in self: if not task.allow_billable: @@ -279,6 +279,8 @@ class ProjectTask(models.Model): task.sale_order_id = task.sale_line_id.sudo().order_id elif task.project_id.sale_order_id: task.sale_order_id = task.project_id.sale_order_id + if task.commercial_partner_id != task.sale_order_id.partner_id.commercial_partner_id: + task.sale_order_id = False if task.sale_order_id and not task.partner_id: task.partner_id = task.sale_order_id.partner_id