diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 5ae2b039839..5ce3be00b9a 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -109,11 +109,13 @@ class SaleOrderLine(models.Model): @api.multi @api.depends('product_id') def _compute_qty_delivered_updateable(self): - for line in self: - if line.product_id.type not in ('consu', 'product'): - super(SaleOrderLine, line)._compute_qty_delivered_updateable() - else: - line.qty_delivered_updateable = False + # prefetch field before filtering + self.mapped('product_id') + # on consumable or stockable products, qty_delivered_updateable defaults + # to False; on other lines use the original computation + lines = self.filtered(lambda line: line.product_id.type not in ('consu', 'product')) + lines = lines.with_prefetch(self._prefetch) + super(SaleOrderLine, lines)._compute_qty_delivered_updateable() @api.onchange('product_id') def _onchange_product_id_set_customer_lead(self):