summaryrefslogtreecommitdiff
path: root/addons/account_tax_python/tests
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-05-13 15:26:12 +0200
committerChristophe Simonis <chs@odoo.com>2019-05-13 15:26:12 +0200
commit8dd5a85267b522ba569ab9ed44901f95fffbeb4f (patch)
treeddb62d1e83e1b810b96c05f6819ca66f8d6b4955 /addons/account_tax_python/tests
parent15716642e1975b4f2f29916011a4be29804cda88 (diff)
parent60e71302a38b36214efec1213882f573e3ea453c (diff)
[MERGE] forward port branch saas-12.3 up to 60e71302a38
Diffstat (limited to 'addons/account_tax_python/tests')
-rw-r--r--addons/account_tax_python/tests/__init__.py3
-rw-r--r--addons/account_tax_python/tests/test_tax.py61
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
+ )