diff options
| author | Goffin Simon <sig@odoo.com> | 2015-12-08 15:57:38 +0100 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2015-12-09 09:13:44 +0100 |
| commit | c4fb2c2efc8f9c97eb80e616f508476a75eaa109 (patch) | |
| tree | 876eb262edf778723c3bb2554b1229f6bf58c28b /addons | |
| parent | 6cdcdb872424a2ae47d12ee4d4917169dfd5856f (diff) | |
[FIX] account: Test product_id_change
Test that when an included tax is mapped by a fiscal position, the
included tax must be subtracted to the price of the product.
Inspired from 503820acb6d82a85c0c49ac26f7e7f8cd73851dd
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/tests/__init__.py | 1 | ||||
| -rw-r--r-- | addons/account/tests/test_product_id_change.py | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/addons/account/tests/__init__.py b/addons/account/tests/__init__.py index 75f03b9a8be..d941d95cc53 100644 --- a/addons/account/tests/__init__.py +++ b/addons/account/tests/__init__.py @@ -3,3 +3,4 @@ from . import test_search from . import test_reconciliation from . import test_account_move_closed_period from . import test_fiscal_position +from . import test_product_id_change diff --git a/addons/account/tests/test_product_id_change.py b/addons/account/tests/test_product_id_change.py new file mode 100644 index 00000000000..1bd5154f4ba --- /dev/null +++ b/addons/account/tests/test_product_id_change.py @@ -0,0 +1,50 @@ +from openerp.tests.common import TransactionCase + +class TestProductIdChange(TransactionCase): + """Test that when an included tax is mapped by a fiscal position, the included tax must be + subtracted to the price of the product. + """ + + def setUp(self): + super(TestProductIdChange, self).setUp() + self.fiscal_position_model = self.registry('account.fiscal.position') + self.fiscal_position_tax_model = self.registry('account.fiscal.position.tax') + self.tax_model = self.registry('account.tax') + self.pricelist_model = self.registry('product.pricelist') + self.res_partner_model = self.registry('res.partner') + self.product_tmpl_model = self.registry('product.template') + self.product_model = self.registry('product.product') + self.invoice_line_model = self.registry('account.invoice.line') + + def test_product_id_change(self): + cr, uid = self.cr, self.uid + partner_id = self.res_partner_model.create(cr, uid, dict(name="George")) + tax_include_id = self.tax_model.create(cr, uid, dict(name="Include tax", + type='percent', + amount='0.21', + price_include=True)) + tax_exclude_id = self.tax_model.create(cr, uid, dict(name="Exclude tax", + type='percent', + amount='0.00')) + product_tmpl_id = self.product_tmpl_model.create(cr, uid, dict(name="Voiture", + list_price='121', + standard_price='121', + taxes_id=[(6, 0, [tax_include_id])], + supplier_taxes_id=[(6, 0, [tax_include_id])])) + product_id = self.product_model.create(cr, uid, dict(product_tmpl_id=product_tmpl_id)) + product = self.product_model.browse(cr, uid, [product_id]) + fp_id = self.fiscal_position_model.create(cr, uid, dict(name="fiscal position", + sequence=1)) + fp_tax_id = self.fiscal_position_tax_model.create(cr, uid, dict(position_id=fp_id, + tax_src_id=tax_include_id, + tax_dest_id=tax_exclude_id)) + + res = self.invoice_line_model.product_id_change(cr, uid, [], product.id, product.uom_id.id, + qty=1, type='out_invoice', partner_id=partner_id, + fposition_id=fp_id) + self.assertEquals(100, res['value']['price_unit'], "The included tax must be subtracted to the price") + + res = self.invoice_line_model.product_id_change(cr, uid, [], product.id, product.uom_id.id, + qty=1, type='in_invoice', partner_id=partner_id, + fposition_id=fp_id) + self.assertEquals(100, res['value']['price_unit'], "The included tax must be subtracted to the price") |
