[FIX] sale: do not always overwrite discount on soline

Before this commit, the discount on a so line was always brought to zero when changing the price

After this commit, we do this only when the pricelist is supposed to compute the discount

OPW 1867262
closes #25851
This commit is contained in:
Lucas Perais (lpe)
2018-08-07 11:04:29 +02:00
parent 9609f79cad
commit db994ca57a
+1 -1
View File
@@ -1007,13 +1007,13 @@ class SaleOrderLine(models.Model):
@api.onchange('product_id', 'price_unit', 'product_uom', 'product_uom_qty', 'tax_id')
def _onchange_discount(self):
self.discount = 0.0
if not (self.product_id and self.product_uom and
self.order_id.partner_id and self.order_id.pricelist_id and
self.order_id.pricelist_id.discount_policy == 'without_discount' and
self.env.user.has_group('sale.group_discount_per_so_line')):
return
self.discount = 0.0
product = self.product_id.with_context(
lang=self.order_id.partner_id.lang,
partner=self.order_id.partner_id.id,