def _format_iban(string):
'''
- This function removes all characters from given 'string' that isn't a alpha numeric and converts it to lower case.
+ This function removes all characters from given 'string' that isn't a alpha numeric and converts it to upper case.
'''
res = ""
for char in string:
if char.isalnum():
- res += char.lower()
+ res += char.upper()
return res
class res_partner_bank(osv.osv):
_inherit = "res.partner.bank"
- def create(self, cr, uid, vals, context={}):
+ def create(self, cr, uid, vals, context=None):
#overwrite to format the iban number correctly
if 'iban' in vals and vals['iban']:
vals['iban'] = _format_iban(vals['iban'])
return super(res_partner_bank, self).create(cr, uid, vals, context)
- def write(self, cr, uid, ids, vals, context={}):
+ def write(self, cr, uid, ids, vals, context=None):
#overwrite to format the iban number correctly
if 'iban' in vals and vals['iban']:
vals['iban'] = _format_iban(vals['iban'])
return super(res_partner_bank, self).write(cr, uid, ids, vals, context)
- def check_iban(self, cr, uid, ids):
+ def check_iban(self, cr, uid, ids, context=None):
'''
Check the IBAN number
'''
- for bank_acc in self.browse(cr, uid, ids):
+ for bank_acc in self.browse(cr, uid, ids, context=context):
if not bank_acc.iban:
continue
- iban = _format_iban(bank_acc.iban)
+ iban = _format_iban(bank_acc.iban).lower()
if iban[:2] in _iban_len and len(iban) != _iban_len[iban[:2]]:
return False
#the four first digits have to be shifted to the end
return False
return True
- def _construct_constraint_msg(self, cr, uid, ids):
+ def _construct_constraint_msg(self, cr, uid, ids, context=None):
def default_iban_check(iban_cn):
return iban_cn[0] in string.ascii_lowercase and iban_cn[1] in string.ascii_lowercase
def name_get(self, cr, uid, ids, context=None):
res = []
to_check_ids = []
- for id in self.browse(cr, uid, ids):
+ for id in self.browse(cr, uid, ids, context=context):
if id.state=='iban':
res.append((id.id,id.iban))
else:
to_check_ids.append(id.id)
- res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context)
+ res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context=context)
return res
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
'ch': lambda x: x[9:],
'gb': lambda x: x[14:],
}
- for record in self.browse(cr, uid, ids, context):
+ for record in self.browse(cr, uid, ids, context=context):
if not record.iban:
res[record.id] = False
continue