I would like to change the label of a field called "target_field", if the selection field contract_type changed the value to sale. This belongs to the view of the contract_type:
<field name="contract_type" on_change="on_change_contract_type(contract_type)"/>
<field name="target_field">
And here the corresponding on_change method.
def on_change_contract_type(self, cr, uid, ids, contract_type, context={}):
res={}
if contract_type == 'sale':
res['target_field']['label'] = 'Sales Contract'
return {'value': res}
I know it doesn't work, because ['label'] does not excist. But is there any way, to set it by code? An other option which is working is to play with attrs und invisible attributes directly in the xml file, but it is a bad coding design approach in my opinion.
I just bumped into the same issue. I will keep an eye on this post, or if I find the solution I will return with it.