[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) <jcb@odoo.com>
Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2023-07-21 11:35:05 +02:00
parent 13a4df94b1
commit f71bb322f6
+1 -1
View File
@@ -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']))