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:
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).lower()
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
iban_country = self.browse(cr, uid, ids)[0].iban[:2]
if default_iban_check(iban_country):
iban_example = iban_country in _ref_iban and _ref_iban[iban_country] + ' \nWhere A = Account number, B = National bank code, S = Branch code, C = account No, N = branch No, K = National check digits....' or ''
- return _('The IBAN does not seems to be correct. You should have entered something like this %s'), (iban_example)
+ return _('The IBAN does not seem to be correct. You should have entered something like this %s'), (iban_example)
return _('The IBAN is invalid, It should begin with the country code'), ()
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