diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py index 41815fe5c4c..f2596d064de 100644 --- a/addons/account/models/account_tax.py +++ b/addons/account/models/account_tax.py @@ -59,7 +59,7 @@ class AccountTaxGroup(models.Model): "If not set, the tax group will be displayed after the 'Untaxed amount' subtotal.", ) - @api.depends('company_id.account_fiscal_country_id') + @api.depends('company_id') def _compute_country_id(self): for group in self: group.country_id = group.company_id.account_fiscal_country_id or group.company_id.country_id @@ -219,7 +219,7 @@ class AccountTax(models.Model): if tax.is_used: raise ValidationError(_("This tax has been used in transactions. For that reason, it is forbidden to modify this field.")) - @api.depends('company_id.account_fiscal_country_id') + @api.depends('company_id') def _compute_country_id(self): for tax in self: tax.country_id = tax.company_id.account_fiscal_country_id or tax.company_id.country_id or tax.country_id diff --git a/addons/account/tests/common.py b/addons/account/tests/common.py index f6ae9050dc9..b11780425e7 100644 --- a/addons/account/tests/common.py +++ b/addons/account/tests/common.py @@ -178,6 +178,16 @@ class AccountTestInvoicingCommon(TransactionCase): cls.inbound_payment_method_line = bank_journal.inbound_payment_method_line_ids[0] cls.outbound_payment_method_line = bank_journal.outbound_payment_method_line_ids[0] + @classmethod + def change_company_country(cls, company, country): + company.country_id = country + company.account_fiscal_country_id = country + for model in ('account.tax', 'account.tax.group'): + cls.env.add_to_compute( + cls.env[model]._fields['country_id'], + cls.env[model].search([('company_id', '=', company.id)]), + ) + @classmethod def setup_company_data(cls, company_name, chart_template=None, **kwargs): ''' Create a new company having the name passed as parameter. diff --git a/addons/sale/tests/test_sale_prices.py b/addons/sale/tests/test_sale_prices.py index 68fa2a6668a..b8f3a87ca1d 100644 --- a/addons/sale/tests/test_sale_prices.py +++ b/addons/sale/tests/test_sale_prices.py @@ -23,7 +23,13 @@ class TestSalePrices(SaleCommon): # Needed when run without demo data # s.t. taxes creation doesn't fail - cls.env.company.account_fiscal_country_id = cls.env.ref('base.be') + belgium = cls.env.ref('base.be') + cls.env.company.account_fiscal_country_id = belgium + for model in ('account.tax', 'account.tax.group'): + cls.env.add_to_compute( + cls.env[model]._fields['country_id'], + cls.env[model].search([('company_id', '=', cls.env.company.id)]), + ) def _create_discount_pricelist_rule(self, **additional_values): return self.env['product.pricelist.item'].create({