[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) <trj@odoo.com>
Signed-off-by: Khanalizadeh Ahmad (khah) <khah@odoo.com>
This commit is contained in:
Ahmad Khanalizadeh
2023-01-10 21:39:46 +01:00
parent c1b826c495
commit b29eea8022
+1 -1
View File
@@ -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),