[MERGE] lp:~xrg/openobject-addons/trunk-patch18
[odoo/odoo.git] / addons / base_iban / base_iban.py
index 345c0b8..f473bd0 100644 (file)
@@ -62,12 +62,12 @@ _ref_iban = { 'al':'ALkk BBBS SSSK CCCC CCCC CCCC CCCC', 'ad':'ADkk BBBB SSSS CC
 
 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):
@@ -75,14 +75,12 @@ class res_partner_bank(osv.osv):
 
     def create(self, cr, uid, vals, context=None):
         #overwrite to format the iban number correctly
-        if not context: context = {}
         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=None):
         #overwrite to format the iban number correctly
-        if not context: context = {}
         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)
@@ -91,11 +89,10 @@ class res_partner_bank(osv.osv):
         '''
         Check the IBAN number
         '''
-        if not context: context = {}
         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
@@ -120,13 +117,12 @@ class res_partner_bank(osv.osv):
         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 = []
-        if not context: context = {}
         for id in self.browse(cr, uid, ids, context=context):
             if id.state=='iban':
                 res.append((id.id,id.iban))
@@ -137,7 +133,6 @@ class res_partner_bank(osv.osv):
 
     def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
     #overwrite the search method in order to search not only on bank type == basic account number but also on type == iban
-        if not context: context = {}
         res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, order, context=context, count=count)
         if filter(lambda x:x[0]=='acc_number' ,args):
             #get the value of the search
@@ -156,7 +151,6 @@ class res_partner_bank(osv.osv):
         This function returns the bank account number computed from the iban account number, thanks to the mapping_list dictionary that contains the rules associated to its country.
         '''
         res = {}
-        if not context: context = {}
         mapping_list = {
          #TODO add rules for others countries
             'be': lambda x: x[4:],