I have a select box in account.invoice.line named form_type. It has three choices:
1) form_a
2) form_b
3) form_c
There is also an integer field named flag in account.invoice.line. When form_c is selected, the flag value must be set to 1; otherwise, if either form_a or form_b is selected, the flag value must be set to 0. I wrote an exchange function in this case, but it does not work. Can anybody help me? What is wrong in my code?
def onchange_form_type(self, cr, uid, ids, invoice, context=None):
val={}
flag=0
invoice = self.pool.get('account.invoice.line').browse(cr, uid, invoice)
for invoice in self.browse(cr, uid, ids, context=context):
if invoice.form_type=="form_c":
flag="1"
else:
flag="0"
print flag
val = { 'flag': flag, }
return {'value': val}
My xml in account.invoice.line for sharing:
<field name="form_type" on_change="onchange_form_type(form_type)"/>
source
share