>>> model :
....
class obj1(osv.osv):
_name = "test.modex.obj1"
_columns = {
'name': fields.char('name', size=50, select=True, required=True),
'surname': fields.char('surname', size=50, select=True),
'grade': fields.char('Grade', size=2, select=True),
}
def onchange_test(self, cr, uid, ids, name, surname, context):
print '-- onchange_test --'
print context
return {}
def my_func(self, cr, uid, ids, context={}):
# do stuff using the info passed in the context variable...
print '-- my_func --'
print context
.....
>>> view :
....
<record id="view_obj1_form" model="ir.ui.view">
<field name="name">test.modex.obj1.form</field>
<field name="model">test.modex.obj1</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<field name="name"/>
<field name="surname" on_change="onchange_test(name,surname,context)" context="{'myname' : name, 'mygrade':grade}"/>
<field name="grade"/>
<newline/>
<button string="Click Me" type="object" name="my_func" context="{'param' : 'value'}" />
</form>
</field>
</record>
.....
>>> view on browser :
>>> result on server :
-- onchange_test --
{'lang': 'en_US', 'tz': False, 'uid': 3, 'mygrade': 'A', 'myname': 'xxxx'}
-- my_func --
{'lang': 'en_US', 'tz': False, 'uid': 3, 'param': 'value'}
No comments:
Post a Comment