Hi,
onchange function for many2many field not working.
I want if the payment form related to the contract was in paid status. The contract form will also be update.
class contract_co(models.Model):
_name = 'contract.co'
payment_ids = fields.Many2many('account.payment', 'contract_payment_rel', 'contract_id', 'payment_id', string="Payments", copy=False, readonly=True)
@api.onchange('payment_ids')
def _onchange_payment_ids(self):
if self.payment_ids:
if (self.contract_amount == self.payment_ids.amount and self.payment_ids.state == 'paid'):
self.state= 'paid'