@api.depends('partner_id', 'payment_date')
def _compute_l10n_ar_withholding_ids(self):
for wizard in self:
date = wizard.payment_date or fields.Date.context_today(self)
partner_taxes = self.env['l10n_ar.partner.tax'].search([
*self.env['l10n_ar.partner.tax']._check_company_domain(wizard.company_id),
'|', ('from_date', '>=', date), ('from_date', '=', False),
'|', ('to_date', '<=', date), ('to_date', '=', False),
('partner_id', '=', wizard.partner_id.commercial_partner_id.id),
('tax_id.l10n_ar_withholding_payment_type', '=', wizard.partner_type),
('tax_id.active', '=', True)
])
wizard.l10n_ar_withholding_ids = [Command.clear()] + [Command.create({'tax_id': x.tax_id.id}) for x in partner_taxes]
In Argentina pay witholding documentation To date and From do not do what they say. In account_payment_register.py:132-144 it says that withholding will not be applied if date is after
from_date(orfrom_dateis empty) or if date is beforeto_date, which is exactly the opposite of what documentation says.It could be a bug in code, but I think that
from_dateandto_datewere intended to set an exemption for this withholding, that is when that withholding does not to apply to a specific range because tax Agency wanted to make an exemption.