From ca9274b9d6d0e16e9bf7e3d8c1290a9696e925e0 Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Tue, 29 Oct 2024 17:32:22 -0300 Subject: [PATCH] [IMP] account_withholding: multi l10n Avoid configure and create taxes with tax_type_use options "Customer Payment" or "Supplier Payment" if not Argentina company Ticket 81960 --- account_withholding/models/account_tax.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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"))