|
|
by_country_company = defaultdict(self.browse)
for tax in self:
if (
not tax.tax_group_id
or tax.tax_group_id.country_id != tax.country_id
or tax.tax_group_id.company_id != tax.company_id
):
by_country_company[(tax.country_id, tax.company_id)] += tax
for (country, company), taxes in by_country_company.items():
taxes.tax_group_id = self.env['account.tax.group'].search([
*self.env['account.tax.group']._check_company_domain(company),
('country_id', '=', country.id),
], limit=1) or self.env['account.tax.group'].search([
*self.env['account.tax.group']._check_company_domain(company),
('country_id', '=', False),
], limit=1)
|
|