[FIX] sale: performance hit in sale.order.line creation (#20417)

The access to the state of sale.order.line (related field) seems very slow for big sale order. Bypassing the related field and using the real field instead, improves performance.
This commit is contained in:
François Honoré (Acsone)
2017-10-27 10:49:24 +02:00
committed by Raphael Collet
parent 088f1e3fdc
commit f51d24d613
+1 -1
View File
@@ -696,7 +696,7 @@ class SaleOrderLine(models.Model):
def create(self, values):
values.update(self._prepare_add_missing_fields(values))
line = super(SaleOrderLine, self).create(values)
if line.state == 'sale':
if line.order_id.state == 'sale':
line._action_procurement_create()
msg = _("Extra line with %s ") % (line.product_id.display_name,)
line.order_id.message_post(body=msg)