[IMP] sale: clean product sale warning onchange part

Simplify the code, and do not instantiate useless variables when not 
needed.
This commit is contained in:
Victor Feyens
2021-06-21 16:52:31 +00:00
parent 4ddf8f279f
commit 62f6dc8af3
+6 -10
View File
@@ -625,20 +625,16 @@ class SaleOrderLine(models.Model):
vals['price_unit'] = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)
self.update(vals)
title = False
message = False
result = {}
warning = {}
if product.sale_line_warn != 'no-message':
title = _("Warning for %s", product.name)
message = product.sale_line_warn_msg
warning['title'] = title
warning['message'] = message
result = {'warning': warning}
if product.sale_line_warn == 'block':
self.product_id = False
return result
return {
'warning': {
'title': _("Warning for %s", product.name),
'message': product.sale_line_warn_msg,
}
}
@api.onchange('product_uom', 'product_uom_qty')
def product_uom_change(self):