Set country values to tax rule line from template

issue5402
review17941002
This commit is contained in:
Cédric Krier
2016-03-21 23:37:35 +01:00
parent acd610077b
commit 63848d5a7c
2 changed files with 33 additions and 1 deletions
+11
View File
@@ -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
+22 -1
View File
@@ -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()