Force upper case for state/country code
bzr revid: ced-e884e4e3cbf4099c2356627c3da0277772660b19
This commit is contained in:
parent
38ddf6d439
commit
21a2cfd693
|
@ -44,6 +44,7 @@ class res_partner_function(osv.osv):
|
||||||
_order = 'name'
|
_order = 'name'
|
||||||
res_partner_function()
|
res_partner_function()
|
||||||
|
|
||||||
|
|
||||||
class res_country(osv.osv):
|
class res_country(osv.osv):
|
||||||
_name = 'res.country'
|
_name = 'res.country'
|
||||||
_description = 'Country'
|
_description = 'Country'
|
||||||
|
@ -55,6 +56,7 @@ class res_country(osv.osv):
|
||||||
('name_uniq', 'unique (name)', 'The name of the country must be unique !'),
|
('name_uniq', 'unique (name)', 'The name of the country must be unique !'),
|
||||||
('code_uniq', 'unique (code)', 'The code of the country must be unique !')
|
('code_uniq', 'unique (code)', 'The code of the country must be unique !')
|
||||||
]
|
]
|
||||||
|
|
||||||
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
|
||||||
if not args:
|
if not args:
|
||||||
args=[]
|
args=[]
|
||||||
|
@ -65,6 +67,19 @@ class res_country(osv.osv):
|
||||||
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
|
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context)
|
||||||
return self.name_get(cr, user, ids, context)
|
return self.name_get(cr, user, ids, context)
|
||||||
_order='code'
|
_order='code'
|
||||||
|
|
||||||
|
def create(self, cursor, user, vals, context=None):
|
||||||
|
if 'code' in vals:
|
||||||
|
vals['code'] = vals['code'].upper()
|
||||||
|
return super(res_country, self).create(cursor, user, vals,
|
||||||
|
context=context)
|
||||||
|
|
||||||
|
def write(self, cursor, user, ids, vals, context=None):
|
||||||
|
if 'code' in vals:
|
||||||
|
vals['code'] = vals['code'].upper()
|
||||||
|
return super(res_country, self).write(cursor, user, ids, vals,
|
||||||
|
context=context)
|
||||||
|
|
||||||
res_country()
|
res_country()
|
||||||
|
|
||||||
class res_country_state(osv.osv):
|
class res_country_state(osv.osv):
|
||||||
|
@ -86,6 +101,19 @@ class res_country_state(osv.osv):
|
||||||
ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
|
ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
|
||||||
return self.name_get(cr, user, ids, context)
|
return self.name_get(cr, user, ids, context)
|
||||||
_order = 'code'
|
_order = 'code'
|
||||||
|
|
||||||
|
def create(self, cursor, user, vals, context=None):
|
||||||
|
if 'code' in vals:
|
||||||
|
vals['code'] = vals['code'].upper()
|
||||||
|
return super(res_country_state, self).create(cursor, user, vals,
|
||||||
|
context=context)
|
||||||
|
|
||||||
|
def write(self, cursor, user, ids, vals, context=None):
|
||||||
|
if 'code' in vals:
|
||||||
|
vals['code'] = vals['code'].upper()
|
||||||
|
return super(res_country_state, self).write(cursor, user, ids, vals,
|
||||||
|
context=context)
|
||||||
|
|
||||||
res_country_state()
|
res_country_state()
|
||||||
|
|
||||||
class res_payterm(osv.osv):
|
class res_payterm(osv.osv):
|
||||||
|
|
|
@ -193,4 +193,12 @@ if cr.fetchall():
|
||||||
cr.execute('ALTER TABLE stock_production_lot DROP CONSTRAINT \'stock_production_lot_name_uniq\'')
|
cr.execute('ALTER TABLE stock_production_lot DROP CONSTRAINT \'stock_production_lot_name_uniq\'')
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
|
# ------------------------------------ #
|
||||||
|
# Put country/state code in upper case #
|
||||||
|
# ------------------------------------ #
|
||||||
|
|
||||||
|
cr.execute('UPDATE res_country SET code = UPPER(code)')
|
||||||
|
cr.execute('UPDATE res_country_state SET code = UPPER(code)')
|
||||||
|
cr.commit()
|
||||||
|
|
||||||
cr.close
|
cr.close
|
||||||
|
|
Loading…
Reference in New Issue