[FIX] sale_timesheet: correctly trigger compute
Revision fad3ed7ce4 introduced a forced
recompute of `billable_type` which unfortunately has repercutions
(compute triggers) upon every single task of a project, meaning that it
will not scale properly as the number of tasks grows and it is now
called everytime we want to access a project view form whch is a
terrible performance drop.
The underlying issue that it tried to address was that the field
billable_type was not correctly computed when deleting the linked
sale_order_id from the project. This happens because when deleting a
record, it is PSQL that sets relational m2o value (in this cas
sale_order_id to NULL and the ORM has no way to catch that information.
A proper fix consists to change the dependency of the computed field
from the m2o to one of its fields. This will properly mark
'billable_type' to be recomputed when unlinking the sale order.
Note that to avoid useless recomputation which would lead to the sale
result, we rely on a filed that should not change once the sale order is
created.
closes odoo/odoo#54817
X-original-commit: 4f2b532c3ef4ebd9beb2a448f59c4e645ba1e8a1
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
@@ -61,13 +61,12 @@ class Project(models.Model):
|
||||
@api.depends('billable_type', 'allow_billable', 'sale_order_id', 'partner_id')
|
||||
def _compute_display_create_order(self):
|
||||
for project in self:
|
||||
project._compute_billable_type()
|
||||
show = True
|
||||
if not project.partner_id or project.billable_type != 'no' or project.allow_billable or project.sale_order_id:
|
||||
show = False
|
||||
project.display_create_order = show
|
||||
|
||||
@api.depends('sale_order_id', 'sale_line_id', 'sale_line_employee_ids')
|
||||
@api.depends('sale_order_id.create_date', 'sale_line_id', 'sale_line_employee_ids')
|
||||
def _compute_billable_type(self):
|
||||
for project in self:
|
||||
billable_type = 'no'
|
||||
|
||||
Reference in New Issue
Block a user