From f51d24d613f2bf125e54f0f87fd00e3e68688d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Honor=C3=A9=20=28Acsone=29?= <30529208+acsonefho@users.noreply.github.com> Date: Fri, 27 Oct 2017 10:49:24 +0200 Subject: [PATCH] [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. --- addons/sale/models/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 40ce0e98088..947aa121a89 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -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)