Debian Codegraph @

addons/l10n_ar_withholding/models/account_payment.py

raw
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2 from odoo import models, fields
3
4
5 class AccountPayment(models.Model):
6 _inherit = 'account.payment'
7
8 l10n_ar_withholding_ids = fields.One2many(related='move_id.l10n_ar_withholding_ids')
9
10 def _synchronize_to_moves(self, changed_fields):
11 ''' If we change a payment with withholdings, delete all withholding lines as the synchronization mechanism is not
12 implemented yet
13 '''
14 if not any(field_name in changed_fields for field_name in self._get_trigger_fields_to_synchronize()):
15 return
16 for pay in self:
17 pay.move_id.line_ids.filtered(
18 lambda x:
19 x.account_id == pay.company_id.l10n_ar_tax_base_account_id or
20 x.tax_line_id.l10n_ar_withholding_payment_type
21 ).unlink()
22 res = super()._synchronize_to_moves(changed_fields)
23 return res