summaryrefslogtreecommitdiff
path: root/addons/account/tests/test_account_move_rounding.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/account/tests/test_account_move_rounding.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/account/tests/test_account_move_rounding.py')
-rw-r--r--addons/account/tests/test_account_move_rounding.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/addons/account/tests/test_account_move_rounding.py b/addons/account/tests/test_account_move_rounding.py
new file mode 100644
index 00000000..92f76b7c
--- /dev/null
+++ b/addons/account/tests/test_account_move_rounding.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+
+from odoo.addons.account.tests.common import AccountTestInvoicingCommon
+from odoo.tests import tagged
+
+
+@tagged('post_install', '-at_install')
+class TestAccountMoveRounding(AccountTestInvoicingCommon):
+
+ def test_move_line_rounding(self):
+ """Whatever arguments we give to the creation of an account move,
+ in every case the amounts should be properly rounded to the currency's precision.
+ In other words, we don't fall victim of the limitation introduced by 9d87d15db6dd40
+
+ Here the rounding should be done according to company_currency_id, which is a related
+ on move_id.company_id.currency_id.
+ In principle, it should not be necessary to add it to the create values,
+ since it is supposed to be computed by the ORM...
+ """
+ move = self.env['account.move'].create({
+ 'line_ids': [
+ (0, 0, {'debit': 100.0 / 3, 'account_id': self.company_data['default_account_revenue'].id}),
+ (0, 0, {'credit': 100.0 / 3, 'account_id': self.company_data['default_account_revenue'].id}),
+ ],
+ })
+
+ self.assertEqual(
+ [(33.33, 0.0), (0.0, 33.33)],
+ move.line_ids.mapped(lambda x: (x.debit, x.credit)),
+ "Quantities should have been rounded according to the currency."
+ )