account.invoice.line に form_type という名前の選択フィールドがあります。次の 3 つの選択オプションがあります。
1) form_a
2) form_b
3) form_c
また、account.invoice.line にはflagという名前の整数フィールドがあります。form_c が選択されている場合、フラグ値は 1 に設定する必要があります。それ以外の場合、form_a または form_b のいずれかが選択されている場合は、フラグ値を 0 に設定する必要があります。上記のケースのonchange関数を作成しましたが、機能しません。誰かが私を助けることができますか?私のコードで何が間違っていますか?
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}
onchange の account.invoice.line の XML コードは次のとおりです。
<field name="form_type" on_change="onchange_form_type(form_type)"/>