[MERGE] [IMP] company: add onchange on state to match country
bzr revid: mat@openerp.com-20130530141819-evvqnmm029uf486h
This commit is contained in:
commit
8c0dfaa9b8
|
@ -137,7 +137,7 @@ class res_company(osv.osv):
|
|||
'street2': fields.function(_get_address_data, fnct_inv=_set_address_data, size=128, type='char', string="Street2", multi='address'),
|
||||
'zip': fields.function(_get_address_data, fnct_inv=_set_address_data, size=24, type='char', string="Zip", multi='address'),
|
||||
'city': fields.function(_get_address_data, fnct_inv=_set_address_data, size=24, type='char', string="City", multi='address'),
|
||||
'state_id': fields.function(_get_address_data, fnct_inv=_set_address_data, type='many2one', domain="[('country_id', '=', country_id)]", relation='res.country.state', string="Fed. State", multi='address'),
|
||||
'state_id': fields.function(_get_address_data, fnct_inv=_set_address_data, type='many2one', relation='res.country.state', string="Fed. State", multi='address'),
|
||||
'bank_ids': fields.one2many('res.partner.bank','company_id', 'Bank Accounts', help='Bank accounts related to this company'),
|
||||
'country_id': fields.function(_get_address_data, fnct_inv=_set_address_data, type='many2one', relation='res.country', string="Country", multi='address'),
|
||||
'email': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Email", multi='address'),
|
||||
|
@ -174,12 +174,18 @@ class res_company(osv.osv):
|
|||
res += '\n%s: %s' % (title, ', '.join(name for id, name in account_names))
|
||||
|
||||
return {'value': {'rml_footer': res, 'rml_footer_readonly': res}}
|
||||
|
||||
def onchange_state(self, cr, uid, ids, state_id, context=None):
|
||||
if state_id:
|
||||
return {'value':{'country_id': self.pool.get('res.country.state').browse(cr, uid, state_id, context).country_id.id }}
|
||||
return {}
|
||||
def on_change_country(self, cr, uid, ids, country_id, context=None):
|
||||
res = {'domain': {'state_id': []}}
|
||||
currency_id = self._get_euro(cr, uid, context=context)
|
||||
if country_id:
|
||||
currency_id = self.pool.get('res.country').browse(cr, uid, country_id, context=context).currency_id.id
|
||||
return {'value': {'currency_id': currency_id}}
|
||||
res['domain'] = {'state_id': [('country_id','=',country_id)]}
|
||||
res['value'] = {'currency_id': currency_id}
|
||||
return res
|
||||
|
||||
def _search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False, access_rights_uid=None):
|
||||
|
@ -253,7 +259,7 @@ class res_company(osv.osv):
|
|||
vals.update({'partner_id': partner_id})
|
||||
self.cache_restart(cr)
|
||||
company_id = super(res_company, self).create(cr, uid, vals, context=context)
|
||||
obj_partner.write(cr, uid, partner_id, {'company_id': company_id}, context=context)
|
||||
obj_partner.write(cr, uid, [partner_id], {'company_id': company_id}, context=context)
|
||||
return company_id
|
||||
|
||||
def write(self, cr, uid, ids, values, context=None):
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<field name="street2"/>
|
||||
<div>
|
||||
<field name="city" placeholder="City" style="width: 40%%"/>
|
||||
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 24%%" options='{"no_open": True}'/>
|
||||
<field name="state_id" class="oe_no_button" placeholder="State" on_change="onchange_state(state_id)" style="width: 24%%" options='{"no_open": True}'/>
|
||||
<field name="zip" placeholder="ZIP" style="width: 34%%"/>
|
||||
</div>
|
||||
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' on_change="on_change_country(country_id)"/>
|
||||
|
|
Loading…
Reference in New Issue