From 5faf5a0dcf4c06716d6a29686d49409b22b05565 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Wed, 10 Apr 2024 14:06:59 +0200 Subject: [PATCH] [FIX] sale_project, sale_timesheet: remove commercial partner Steps to reproduce: ------------------- - create a partner which is "individual"; - create a project (with timesheets and billable); - create a task A with timesheets; - link the task A to a sale order line with the partner created; - create a sub task A in task A with timesheets; - remove the sale order line linked to sub task A; - change the partner to "Company" Issue: ------ The sale order line is added to subtask A. The sale order to the partner will not be correct. Cause: ------ We trigger the logic `_compute_sale_line` when the `is_company` of the partner is modified. This is due to the construction of the dependencies, which takes implicit dependencies into account. Solution: --------- Remove the dependency and keep only the dependency with `partner_id` because it is an ORM limitation. opw-3836986 closes odoo/odoo#161305 Signed-off-by: Xavier Bol (xbo) --- addons/sale_project/models/project.py | 2 +- addons/sale_timesheet/models/project.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale_project/models/project.py b/addons/sale_project/models/project.py index 8e3cd0b65c7..dc4ac212e01 100755 --- a/addons/sale_project/models/project.py +++ b/addons/sale_project/models/project.py @@ -838,7 +838,7 @@ class ProjectTask(models.Model): (self - billable_task).partner_id = False super(ProjectTask, billable_task)._compute_partner_id() - @api.depends('partner_id.commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'milestone_id.sale_line_id', 'allow_billable') + @api.depends('partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'milestone_id.sale_line_id', 'allow_billable') def _compute_sale_line(self): for task in self: if not (task.allow_billable or task.parent_id.allow_billable): diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index f76a8352b75..32fa34ebd55 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -583,7 +583,7 @@ class ProjectTask(models.Model): for task in self: task.analytic_account_active = task.analytic_account_active or task.so_analytic_account_id.active - @api.depends('partner_id.commercial_partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable') + @api.depends('partner_id', 'sale_line_id.order_partner_id', 'parent_id.sale_line_id', 'project_id.sale_line_id', 'allow_billable') def _compute_sale_line(self): super()._compute_sale_line() for task in self: