From b29eea80226090108472a97d6172dd65abbc64dc Mon Sep 17 00:00:00 2001 From: Ahmad Khanalizadeh Date: Tue, 10 Jan 2023 09:39:17 +0000 Subject: [PATCH] [FIX] point_of_sale: use float comparison in discount lines Before this commit if there is a rounding error in product list prices, a note is added to the invoices indicating that a discount is in effect, while that is not the case. Exact steps to reproduce: 1. Create a new tax with the amount of 21% 2. Make it included in the price 3. Create a new product with price of 1.65$ (1.36$ excluding tax) 4. Open a PoS session, add the product to the error 5. Enable invoicing and validate the payment To fix this, the float comparison methods should be used. opw-3121143 closes odoo/odoo#109585 X-original-commit: 238532f396bbc3d4fbe14d75e756307536dfe3c6 Signed-off-by: Trinh Jacky (trj) Signed-off-by: Khanalizadeh Ahmad (khah) --- addons/point_of_sale/models/pos_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 9098e169f7d..028544a33be 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -204,7 +204,7 @@ class PosOrder(models.Model): invoice_lines = [] for line in self.lines: invoice_lines.append((0, None, self._prepare_invoice_line(line))) - if line.order_id.pricelist_id.discount_policy == 'without_discount' and line.price_unit != line.product_id.lst_price: + if line.order_id.pricelist_id.discount_policy == 'without_discount' and float_compare(line.price_unit, line.product_id.lst_price, precision_rounding=self.currency_id.rounding): invoice_lines.append((0, None, { 'name': _('Price discount from %s -> %s', float_repr(line.product_id.lst_price, self.currency_id.decimal_places),