diff --git a/account_withholding/models/account_tax.py b/account_withholding/models/account_tax.py index c68683153..943da5186 100644 --- a/account_withholding/models/account_tax.py +++ b/account_withholding/models/account_tax.py @@ -1,6 +1,6 @@ -from odoo import models, fields, api +from odoo import models, fields, api, _ from odoo.addons.account.models.account_tax import TYPE_TAX_USE - +from odoo.exceptions import ValidationError TYPE_TAX_USE += [('customer', 'Customer Payment'), ('supplier', 'Supplier Payment')] @@ -41,3 +41,12 @@ def create(self, vals_list): 'company_id': tax.company_id.id, }).id return recs + + @api.constrains('type_tax_use') + def check_type_tax_use_ar(self): + """ Las opciones "Customer Payment" y "Supplier Payment" estan definidas solo para ser usadas en la + lógica de compañias con loc argentina, evitamos el uso de esta configuracion de impuestos para otras + localizaciones """ + if self.filtered(lambda x: x.type_tax_use in ["customer", "supplier"] and x.country_code != "AR"): + raise ValidationError(_( + "Este Tipo de Impuesto es solo compatible en compañias con Localización Argentina"))