[IMP] account: tax tags: add a constraint ensuring a country is always set on tax tags
The use of such tags was not supported if no country was set on them (we need one to properly filter what to display in tax configuration). We just make it explicit by adding this constraint. closes odoo/odoo#47813 X-original-commit: f76c2d92c58b2055bc906b32d47f192c615a46ed Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com> Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
@@ -12568,3 +12568,9 @@ msgstr ""
|
||||
#: model_terms:ir.ui.view,arch_db:account.view_bank_statement_form
|
||||
msgid "→ Count"
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account.py:56
|
||||
#, python-format
|
||||
msgid "A tag defined to be used on taxes must always have a country set."
|
||||
msgstr ""
|
||||
|
||||
@@ -66,6 +66,12 @@ class AccountAccountTag(models.Model):
|
||||
escaped_tag_name = tag_name.replace('\\', '\\\\').replace('%', '\%').replace('_', '\_')
|
||||
return self.env['account.account.tag'].search([('name', '=like', '_' + escaped_tag_name), ('country_id', '=', country_id), ('applicability', '=', 'taxes')])
|
||||
|
||||
@api.constrains('country_id', 'applicability')
|
||||
def _validate_tag_country(self):
|
||||
for record in self:
|
||||
if record.applicability == 'taxes' and not record.country_id:
|
||||
raise ValidationError(_("A tag defined to be used on taxes must always have a country set."))
|
||||
|
||||
|
||||
class AccountTaxReport(models.Model):
|
||||
_name = "account.tax.report"
|
||||
|
||||
@@ -143,6 +143,7 @@ class TestInvoiceTaxes(AccountTestCommon, SavepointCaseWithUserDemo):
|
||||
return self.env['account.account.tag'].create({
|
||||
'name': tag_name,
|
||||
'applicability': 'taxes',
|
||||
'country_id': self.env.company.country_id.id,
|
||||
})
|
||||
|
||||
def test_tax_repartition(self):
|
||||
|
||||
Reference in New Issue
Block a user