From 3e1395b77e8d85c000141d8ccc6e1c9d004d035e Mon Sep 17 00:00:00 2001 From: "Nasreddin (bon)" Date: Thu, 10 Dec 2020 14:59:53 +0000 Subject: [PATCH] [FIX] sale: Traceback on update price (price list) and price = 0 Issue - Create a Price list and set 'Discount Policy' as "Show public price & discount to the customer " - Create an SO - Add a multiple product with at least one with price unit = 0 - Change the pricelist and update prices Cause Division by zero when calculating discount. Solution Calculate discount only if there is a price_unit. opw-2393790 closes odoo/odoo#63218 X-original-commit: 9f70f405bc453ce56b75d22a318c9fd72e8bd496 Signed-off-by: bon-odoo --- addons/sale/models/sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 2df7f0d9f23..df2c8877fa3 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -471,7 +471,7 @@ class SaleOrder(models.Model): ) price_unit = self.env['account.tax']._fix_tax_included_price_company( line._get_display_price(product), line.product_id.taxes_id, line.tax_id, line.company_id) - if self.pricelist_id.discount_policy == 'without_discount': + if self.pricelist_id.discount_policy == 'without_discount' and price_unit: discount = max(0, (price_unit - product.price) * 100 / price_unit) else: discount = 0