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

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

Avatar
Discard
Author

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

Author Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 24
1485
1
Nov 24
1193
2
Sep 24
1047
1
Aug 24
2454
3
Aug 24
2687