I want to change some field values on the invoice when the payment state changes.
This is what I have:
@api.onchange('payment_state')
def update_payment_state(self):
print('working?') # no
invoices = self.env['account.move'].search([])
for invoice in invoices:
invoice.field_to_update = 'OK'
Thank you for any suggestions
SOLVED !
def write(self, values):
invoices = super(AccountExt,self).write(values)
try:
if 'state' in values and values['state']:
for invoice in self.env['account.move'].search([]):
invoice.field_to_update = 'OK'
except Exception: pass
return invoices