From a43cdc3cdd6d8f56d7fdcce2f86323d8b51616a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 31 Oct 2021 18:46:32 +0100 Subject: [PATCH] Search default chart of account properties only for the company issue10924 review375901002 --- account.py | 2 ++ tests/test_account_product.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) 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'