diff --git a/addons/sale/models/sale_order_line.py b/addons/sale/models/sale_order_line.py index 0b21c11a03c..5eed45c08b9 100644 --- a/addons/sale/models/sale_order_line.py +++ b/addons/sale/models/sale_order_line.py @@ -747,9 +747,6 @@ class SaleOrderLine(models.Model): 'tax_id', 'analytic_tag_ids' ] - def _onchange_product_id_set_customer_lead(self): - pass - @api.onchange('product_id', 'price_unit', 'product_uom', 'product_uom_qty', 'tax_id') def _onchange_discount(self): if not (self.product_id and self.product_uom and diff --git a/addons/sale_product_matrix/models/sale_order.py b/addons/sale_product_matrix/models/sale_order.py index 8c31ee77a53..c43c87737f8 100644 --- a/addons/sale_product_matrix/models/sale_order.py +++ b/addons/sale_product_matrix/models/sale_order.py @@ -125,7 +125,6 @@ class SaleOrder(models.Model): for line in self.order_line.filtered(lambda line: line.product_id.id in product_ids): res = line.product_id_change() or res line._onchange_discount() - line._onchange_product_id_set_customer_lead() return res def _get_matrix(self, product_template): diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 3c4343a87c6..7586e9a25d7 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -280,6 +280,8 @@ class SaleOrderLine(models.Model): qty_to_deliver = fields.Float(compute='_compute_qty_to_deliver', digits='Product Unit of Measure') is_mto = fields.Boolean(compute='_compute_is_mto') display_qty_widget = fields.Boolean(compute='_compute_qty_to_deliver') + customer_lead = fields.Float( + compute='_compute_customer_lead', store=True, readonly=False, pre_compute=True) @api.depends('product_type', 'product_uom_qty', 'qty_delivered', 'state', 'move_ids', 'product_uom') def _compute_qty_to_deliver(self): @@ -470,9 +472,10 @@ class SaleOrderLine(models.Model): else: line.product_updatable = False - @api.onchange('product_id') - def _onchange_product_id_set_customer_lead(self): - self.customer_lead = self.product_id.sale_delay + @api.depends('product_id') + def _compute_customer_lead(self): + for order in self: + order.customer_lead = order.product_id.sale_delay def _prepare_procurement_values(self, group_id=False): """ Prepare specific key for moves or other components that will be created from a stock rule