Skip to Content
Menu
This question has been flagged
1 Reply
2788 Views

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'


Avatar
Discard
Best Answer

If I understood correctly you have a relation between contract and payment and when the state of the payment changes, you want it to update both the payment object but also the contract associated with it, right ?

Now what exactly do you want to update? what fields? just the state in both objects?

Avatar
Discard