[FIX] l10n_ar_withholding: Clean up WH Payment Type

Clean up field value when is not used, this because is only
show when some conditions applies, if not we need to clear it to
avoid having wrong data on taxes.

We want to behave as an onchange, to se change the field to a compute
one, in this case stored and also can be edit by the user

closes odoo/odoo#156808

Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
Katherine Zaoral
2024-04-11 16:43:19 +00:00
parent 40abf404c3
commit 30764ebc61
@@ -1,5 +1,5 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
from odoo import api, fields, models
class AccountTax(models.Model):
@@ -7,7 +7,13 @@ class AccountTax(models.Model):
_inherit = 'account.tax'
l10n_ar_withholding_payment_type = fields.Selection(
[('supplier', 'Supplier'), ('customer', 'Customer')], 'Argentinean Withholding type')
[('supplier', 'Supplier'), ('customer', 'Customer')], 'Argentinean Withholding type',
compute="_compute_l10n_ar_withholding_payment_type", store=True, readonly=False)
l10n_ar_withholding_sequence_id = fields.Many2one(
'ir.sequence', 'Withholding Number Sequence', copy=False, check_company=True,
help='If no sequence provided then it will be required for you to enter withholding number when registering one.')
@api.depends('type_tax_use', 'country_code')
def _compute_l10n_ar_withholding_payment_type(self):
self.filtered(lambda x: not x.l10n_ar_withholding_payment_type or x.type_tax_use != 'none' or x.country_code != 'AR').l10n_ar_withholding_payment_type = False