I have one field in my .py file and I've created two different function for it:
scode= fields.Char('Code', size=3, required=True)
def uppercase(self, cr, uid, ids, scode, context=None):
if scode:
result = {'value': {'scode': str(scode).upper()}}
return result
def get_lenght(self, cr, uid, ids, scode, context=None):
if scode and len(scode) != 3:
My_error_Msg = 'Error'
raise osv.except_osv(("Warning!"), (My_error_Msg))
return
else:
return scode
def onchange_length_id(self, cr, uid, ids, scode, context=None):
res = {'value': {'scode': self.get_lenght(cr, uid, ids, scode, context=context)}}
return res
Now, my question is: how can I use both functions in my view?
If I had only one method, I would write:
<field name="scode" on_change="uppercase(scode)"/>
Any idea?
Thanks!
Drees based his answer on merging the two methods in one. You can only use one 'on_change' method for a field.