diff --git a/account.py b/account.py index a56a20f98a..6bc619d112 100644 --- a/account.py +++ b/account.py @@ -288,7 +288,7 @@ class Type(ModelSQL, ModelView): if vals: values.append([child]) values.append(vals) - template2type[child.template.id] = child.id + template2type[child.template.id] = child.id childs = sum((c.childs for c in childs), ()) if values: self.write(*values) @@ -897,7 +897,7 @@ class Account(ModelSQL, ModelView): if vals: values.append([child]) values.append(vals) - template2account[child.template.id] = child.id + template2account[child.template.id] = child.id childs = sum((c.childs for c in childs), ()) if values: self.write(*values) diff --git a/tax.py b/tax.py index cb43089210..4c0f1f7869 100644 --- a/tax.py +++ b/tax.py @@ -270,7 +270,7 @@ class TaxCode(ModelSQL, ModelView): if vals: values.append([child]) values.append(vals) - template2tax_code[child.template.id] = child.id + template2tax_code[child.template.id] = child.id childs = sum((c.childs for c in childs), ()) if values: cls.write(*values) @@ -1004,7 +1004,7 @@ class Tax(ModelSQL, ModelView): if vals: values.append([child]) values.append(vals) - template2tax[child.template.id] = child.id + template2tax[child.template.id] = child.id childs = sum((c.childs for c in childs), ()) if values: cls.write(*values) @@ -1548,7 +1548,7 @@ class TaxRuleLine(ModelSQL, ModelView, MatchMixin): if vals: values.append([line]) values.append(vals) - template2rule_line[line.template.id] = line.id + template2rule_line[line.template.id] = line.id if values: cls.write(*values) diff --git a/tests/test_account.py b/tests/test_account.py index 7572f688da..4dd765ec0d 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -103,6 +103,7 @@ class AccountTestCase(ModuleTestCase): 'Test creation and update of minimal chart of accounts' pool = Pool() Account = pool.get('account.account') + Tax = pool.get('account.tax') UpdateChart = pool.get('account.update_chart', type='wizard') company = create_company() @@ -110,6 +111,14 @@ class AccountTestCase(ModuleTestCase): create_chart(company, tax=True) root, = Account.search([('parent', '=', None)]) + # Create an account and tax without template + + cash, = Account.search([('name', '=', 'Main Cash')]) + Account.copy([cash.id]) + + tax, = Tax.search([]) + Tax.copy([tax.id]) + session_id, _, _ = UpdateChart.create() update_chart = UpdateChart(session_id) update_chart.start.account = root