i am trying onchange method programme in openerp using python. but there is no error at the same time there is no response while i change name in field.
xml coding (cus_view.xml)
<?xml version="1.0"?>
<openerp>
<data>
<!-- ===================== This is tree layout =============================-->
<record model = "ir.ui.view" id = "custom_tree">
<field name = "name">Custom</field>
<field name = "model">cus.custom</field>
<field name = "type">form</field>
<field name = "arch1" type = "xml">
<tree string = "custom" version = "7.0">
<field name = "name"/>
<field name = "customer_name"/>
<field name = "customer_street1"/>
<field name = "customer_street2"/>
<field name = "customer_city"/>
<field name = "customer_state"/>
<field name = "customer_zip"/>
<field name = "customer_country"/>
<field name = "customer_mobile"/>
<field name = "customer_mail"/>
</tree>
</field>
</record>
<!-- ========================This is Form layout===============================-->
<record model = "ir.ui.view" id = "custom_form">
<field name = "name">Custom</field>
<field name = "model">cus.custom</field>
<field name = "type">form</field>
<field name = "arch1" type = "xml">
<form string = "custom" version = "7.0">
<label for = "name" string = "Lab Id"/>
<field name = "name" style = "width:10%%" /><br/>
<label for = "customer_name" string = "Customer Name" />
<field name = "customer_name" style = "width:10%%" on_change="on_change_customer(customer_name)" /><br/>
<label for = "Street1" string = "Address"/>
<field name = "customer_street1" style = "width:10%%"/><br/>
<field name = "customer_street2" style = "width:10%%"/><br/>
<field name = "customer_city" style = "width:10%%"/><br/>
<field name = "customer_state" style = "width:10%%"/><br/>
<field name = "customer_zip" style = "width:10%%"/><br/>
<field name = "customer_country" style = "width:10%%"/><br/>
<label for ="customer_mobile" string = "Mobile"/>
<field name = "customer_mobile" style = "width:10%%"/><br/>
<label for ="customer_mail" string = "Email"/>
<field name ="customer_mail" style = "width:10%%"/>
</form>
</field>
</record>
<!-- ========================= Action Layout ============================= -->
<record model = "ir.actions.act_window" id = "action_custom">
<field name = "name">Custom</field>
<field name = "res_model">cus.custom</field>
<field name = "view_type">form</field>
<field name = "view_mode">tree,form</field>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name = "Lab Information" id = "menu_cus_custom" action = "action_custom"/>
</data>
</openerp>
python coding (cus.py) from osv import osv from osv import fields
class cus(osv.osv):
_name = "cus.custom"
_description = "This table is for keeping personal data of student"
_columns = {
'name': fields.char('Lab Id',size=64,required=True),
'customer_name': fields.many2one('res.partner', 'Customer'),
'customer_street1': fields.char('Street', size=64),
'customer_street2': fields.char('Street', size=64),
'customer_city': fields.char('City', size=64),
'customer_state': fields.char('State', size=64),
'customer_zip': fields.char('Zip', size=64),
'customer_country': fields.char('Country', size=64),
'customer_mobile': fields.char('Mobile', size=64),
'customer_mail': fields.char('Mail', size=64)
}
def on_change_customer(self, cr, uid, ids, customer_name, context=None):
values = {}
if customer_name:
cust = self.pool.get('res.partner').browse(cr, uid, customer_name, context=context)
values = {
'customer_country': cust.name
}
return {'value' : values}