[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) <xbo@odoo.com>
This commit is contained in:
Thomas Lefebvre (thle)
2024-04-11 13:16:59 +00:00
parent f8ac11e63b
commit 5faf5a0dcf
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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):
+1 -1
View File
@@ -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: