[IMP]:Improve onchange code for state

bzr revid: aja@tinyerp.com-20121025095805-isdu8d4ma2etx8vc
This commit is contained in:
ajay javiya (OpenERP) 2012-10-25 15:28:05 +05:30
parent e23ade6f5d
commit 569e9037aa
1 changed files with 4 additions and 2 deletions

View File

@ -563,8 +563,10 @@ class res_partner(osv.osv, format_address):
return address_format % args
def onchange_state(self, cr, uid, ids, state_id, context=None):
state=self.pool.get('res.country.state').browse(cr, uid, state_id, context)
return {'value':{'country_id':state.country_id.id,'zip':''}}
if state_id:
state=self.pool.get('res.country.state').browse(cr, uid, state_id, context)
return {'value':{'state_id':state_id,'country_id':state.country_id.id,'zip':''}}
return {'value':{'state_id':state_id,'country_id':'','zip':''}}
# res.partner.address is deprecated; it is still there for backward compability only and will be removed in next version
class res_partner_address(osv.osv):
_table = "res_partner"