diff options
| author | Laurent Smet <las@odoo.com> | 2017-11-14 14:16:49 +0000 |
|---|---|---|
| committer | Olivier Colson <oco@odoo.com> | 2019-05-09 11:56:39 +0000 |
| commit | 4523a11bed332d7cb1f1846d2ff6b54f83afe430 (patch) | |
| tree | 6a9db2abb28cece9ad1420440d36af8ed10aca4c /addons/account_tax_python/tests | |
| parent | 1ab4b61059bef8d240bcc511d2b8fbc9310a6129 (diff) | |
[FIX] account, point_of_sale: Fix complex taxes computation
The previous _compute_all wasn't able to get the right results in case of complex
taxes computation.
See tests for examples.
task: 39945
Diffstat (limited to 'addons/account_tax_python/tests')
| -rw-r--r-- | addons/account_tax_python/tests/__init__.py | 3 | ||||
| -rw-r--r-- | addons/account_tax_python/tests/test_tax.py | 61 |
2 files changed, 64 insertions, 0 deletions
diff --git a/addons/account_tax_python/tests/__init__.py b/addons/account_tax_python/tests/__init__.py new file mode 100644 index 00000000000..b9eada7706e --- /dev/null +++ b/addons/account_tax_python/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_tax diff --git a/addons/account_tax_python/tests/test_tax.py b/addons/account_tax_python/tests/test_tax.py new file mode 100644 index 00000000000..2ad4529cd4b --- /dev/null +++ b/addons/account_tax_python/tests/test_tax.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +from odoo.addons.account.tests.test_tax import TestTax +from odoo.tests import tagged + + +@tagged('post_install', '-at_install') +class TestTaxPython(TestTax): + + def setUp(self): + super(TestTaxPython, self).setUp() + + self.python_tax = self.tax_model.create({ + 'name': 'Python TAx', + 'amount_type': 'code', + 'amount': 0.0, + 'python_compute': 'result = ((price_unit * quantity) - ((price_unit * quantity) / 1.12)) * 0.5', + 'sequence': 1, + }) + + def test_tax_python_basic(self): + res = self.python_tax.compute_all(130.0) + self._check_compute_all_results( + 136.96, # 'total_included' + 130.0, # 'total_excluded' + [ + # base , amount | seq | amount | incl | incl_base + # -------------------------------------------------- + (130.0, 6.96), # | 1 | 6% | t | + # -------------------------------------------------- + ], + res + ) + + def test_tax_python_price_include(self): + self.python_tax.price_include = True + res = self.python_tax.compute_all(130.0) + self._check_compute_all_results( + 130, # 'total_included' + 123.04, # 'total_excluded' + [ + # base , amount | seq | amount | incl | incl_base + # --------------------------------------------------- + (123.04, 6.96), # | 1 | 6% | t | + # --------------------------------------------------- + ], + res + ) + + res = (self.python_tax + self.python_tax).compute_all(130.0) + self._check_compute_all_results( + 130, # 'total_included' + 116.07, # 'total_excluded' + [ + # base , amount | seq | amount | incl | incl_base + # --------------------------------------------------- + (116.07, 6.96), # | 1 | 6% | t | + (116.07, 6.97), # | 1 | 6% | t | + # --------------------------------------------------- + ], + res + ) |
