diff --git a/account.py b/account.py index 515ad98088..3553891c64 100644 --- a/account.py +++ b/account.py @@ -15,6 +15,17 @@ class TaxRuleLineTemplate: to_country = fields.Many2One('country.country', 'To Country', ondelete='RESTRICT') + def _get_tax_rule_line_value(self, rule_line=None): + value = super(TaxRuleLineTemplate, self)._get_tax_rule_line_value( + rule_line=rule_line) + if not rule_line or rule_line.from_country != self.from_country: + value['from_country'] = ( + self.from_country.id if self.from_country else None) + if not rule_line or rule_line.to_country != self.to_country: + value['to_country'] = ( + self.to_country.id if self.to_country else None) + return value + class TaxRuleLine: __metaclass__ = PoolMeta diff --git a/tests/test_account_tax_rule_country.py b/tests/test_account_tax_rule_country.py index 35d8cf119d..8b7f9cd3c7 100644 --- a/tests/test_account_tax_rule_country.py +++ b/tests/test_account_tax_rule_country.py @@ -2,14 +2,35 @@ # this repository contains the full copyright notices and license terms. import unittest +from trytond.pool import Pool import trytond.tests.test_tryton -from trytond.tests.test_tryton import ModuleTestCase +from trytond.tests.test_tryton import ModuleTestCase, with_transaction + +from trytond.modules.company.tests import create_company, set_company +from trytond.modules.account.tests import create_chart class AccountTaxRuleCountryTestCase(ModuleTestCase): 'Test Account Tax Rule Country module' module = 'account_tax_rule_country' + @with_transaction() + def test_account_chart(self): + 'Test creation and update of minimal chart of accounts' + pool = Pool() + Account = pool.get('account.account') + UpdateChart = pool.get('account.update_chart', type='wizard') + + company = create_company() + with set_company(company): + create_chart(company, tax=True) + root, = Account.search([('parent', '=', None)]) + + session_id, _, _ = UpdateChart.create() + update_chart = UpdateChart(session_id) + update_chart.start.account = root + update_chart.transition_update() + def suite(): suite = trytond.tests.test_tryton.suite()