From f71bb322f69b75e90d7e3b79d3cfd4cfa5f9a37e Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Mon, 12 Jun 2023 15:45:00 +0000 Subject: [PATCH] [FIX] point_of_sale: fix rounding issue when closing pos session Current behavior: When the currency in the PoS is not the same currency as the one of the company, and uses a big rates there are sometimes rounding issues. These rounding issues can lead to a difference at closing that prevent you from closing the PoS session. Steps to reproduce: - Make sure atleast 2 currencies are activated. (USD and EUR) - Modify the USD rounding factor to 0.000001 - Modify the rate for the EUR to 2100 Unit/USD - Now go in the PoS settings and go in the Default Journals Order and set the currency to EUR - Change the pricelist currency to EUR - Change the cash payment method journal currency to EUR and remove other payment methods - Open a PoS session and create a new order with 3 products with a price that has decimals - Pay the order with cash - Close the session, you will get an error The error was happening because the rounding was done on each line and therefore we were losing precision. opw-3258806 closes odoo/odoo#129241 X-original-commit: 112e224ace6e658c563d6041532e133ddcc1c8a7 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Robin Engels (roen) --- addons/point_of_sale/models/pos_session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index ea782937f9d..098f34d7a6f 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -749,7 +749,7 @@ class PosSession(models.Model): tuple((tax['id'], tax['account_id'], tax['tax_repartition_line_id']) for tax in line['taxes']), line['base_tags'], ) - sales[sale_key] = self._update_amounts(sales[sale_key], {'amount': line['amount']}, line['date_order']) + sales[sale_key] = self._update_amounts(sales[sale_key], {'amount': line['amount']}, line['date_order'], round=False) # Combine tax lines for tax in line['taxes']: tax_key = (tax['account_id'] or line['income_account_id'], tax['tax_repartition_line_id'], tax['id'], tuple(tax['tag_ids']))