[FIX] sale: Add indexes on some fields

Once sale_project is installed, when trying to add/remove an employee on
the "Invoicing" tab on the project form view for a big internal project,
this decreases the execution time from 20 minutes / timeout to 12 seconds,
by decreasing drastically the execution time of _get_last_sol_of_customer
on sale_line_id recomputation (_compute_sale_line).

closes odoo/odoo#90263

Taskid: 2836314
X-original-commit: 757358449b7514f371415c528b818020f6147335
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Yannick Tivisse
2022-05-01 14:18:42 +02:00
committed by Laurent Stukkens (LTU)
parent bbfb8cb099
commit be3be24737
+1 -1
View File
@@ -47,7 +47,7 @@ class SaleOrderLine(models.Model):
order_partner_id = fields.Many2one(
related='order_id.partner_id',
string="Customer",
store=True, precompute=True)
store=True, index=True, precompute=True)
salesman_id = fields.Many2one(
related='order_id.user_id',
string="Salesperson",