[IMP] sale: Convert _onchange_product_id_set_customer_lead into compute method

This commit is contained in:
Yannick Tivisse
2021-12-02 12:12:02 +01:00
parent a88e7c8717
commit 6a4f437c99
3 changed files with 6 additions and 7 deletions
-3
View File
@@ -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
@@ -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):
+6 -3
View File
@@ -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