From 30764ebc615c28721600d164f47cdf9a7fc6e487 Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Wed, 6 Mar 2024 12:24:51 -0300 Subject: [PATCH] [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 --- addons/l10n_ar_withholding/models/account_tax.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/l10n_ar_withholding/models/account_tax.py b/addons/l10n_ar_withholding/models/account_tax.py index 3b9027bdf02..0ed8f3cc22e 100644 --- a/addons/l10n_ar_withholding/models/account_tax.py +++ b/addons/l10n_ar_withholding/models/account_tax.py @@ -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