diff --git a/account.py b/account.py index d687dbc554..4e7f6c5c3c 100644 --- a/account.py +++ b/account.py @@ -52,9 +52,11 @@ class CreateChart(metaclass=PoolMeta): defaults = super(CreateChart, self).default_properties(fields) expense_accounts = Account.search([ ('type.expense', '=', True), + ('company', '=', self.account.company.id), ], limit=2) revenue_accounts = Account.search([ ('type.revenue', '=', True), + ('company', '=', self.account.company.id), ], limit=2) if len(expense_accounts) == 1: defaults['category_account_expense'] = expense_accounts[0].id diff --git a/tests/test_account_product.py b/tests/test_account_product.py index 5649617c56..b8743148f6 100644 --- a/tests/test_account_product.py +++ b/tests/test_account_product.py @@ -18,6 +18,24 @@ class AccountProductTestCase(CompanyTestMixin, ModuleTestCase): module = 'account_product' extras = ['analytic_account'] + @with_transaction() + def test_account_chart(self): + "Test creation of chart of accounts" + company = create_company() + with set_company(company): + create_chart(company, tax=True) + + @with_transaction() + def test_account_chart_many_companies(self): + "Test creation of chart of accounts for many companies" + company1 = create_company() + with set_company(company1): + create_chart(company1, tax=True) + + company2 = create_company() + with set_company(company2): + create_chart(company2, tax=True) + @with_transaction() def test_account_used(self): 'Test account used'