[FIX] account: less restriction on tax.name
The aim of this commit is to allow having several taxes with the same name if those taxes are from different countries. Context: With the new taxonomy, it was much more likely for 2 taxes to have the same name and that was the case for several taxes. Before this commit: It was impossible to instantiate some foreign tax because of the unicity on tax name constrains. After this commit: - Foreign tax with same name than national tax can be created again - UX is improved by appending the country code to the tax name for display purpose. closes odoo/odoo#137921 Task-id: None X-original-commit: 502ec287590b95fdae581cc048ca25eb6699e16d Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
This commit is contained in:
@@ -186,6 +186,7 @@ class AccountTax(models.Model):
|
||||
('name', '=', record.name),
|
||||
('type_tax_use', '=', record.type_tax_use),
|
||||
('tax_scope', '=', record.tax_scope),
|
||||
('country_id', '=', record.country_id.id),
|
||||
('id', '!=', record.id),
|
||||
])
|
||||
if duplicates := self.search(expression.OR(domains)):
|
||||
@@ -383,6 +384,8 @@ class AccountTax(models.Model):
|
||||
name += ' (%s)' % tax_scope.get(record.tax_scope)
|
||||
if len(self.env.companies) > 1 and self.env.context.get('params', {}).get('model') == 'product.template':
|
||||
name += ' (%s)' % record.company_id.display_name
|
||||
if record.country_id != record.company_id.account_fiscal_country_id:
|
||||
name += ' (%s)' % record.country_code
|
||||
record.display_name = name
|
||||
|
||||
@api.onchange('amount')
|
||||
|
||||
@@ -100,8 +100,8 @@ def data_method_provider(chart_template_name, country_code):
|
||||
'account.tax': {
|
||||
xmlid: _tax_vals(name, amount, external_id_prefix)
|
||||
for name, xmlid, amount in (
|
||||
(f'{external_id_prefix}Tax 1', 'test_tax_1_template', 15),
|
||||
(f'{external_id_prefix}Tax 2', 'test_tax_2_template', 0),
|
||||
('Tax 1', 'test_tax_1_template', 15),
|
||||
('Tax 2', 'test_tax_2_template', 0),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user