[MERGE] with addons-trunk and resolve conflict in base_iban
authorAlexis de Lattre <alexis@via.ecp.fr>
Tue, 31 Jan 2012 13:36:57 +0000 (14:36 +0100)
committerAlexis de Lattre <alexis@via.ecp.fr>
Tue, 31 Jan 2012 13:36:57 +0000 (14:36 +0100)
<> changed to !=
Changed error message

bzr revid: alexis@via.ecp.fr-20120131133657-0gzkk0bcb709ca6f

1  2 
addons/base_iban/base_iban.py
addons/l10n_fr_rib/__openerp__.py
addons/l10n_fr_rib/bank.py

@@@ -95,36 -94,27 +94,36 @@@ class res_partner_bank(osv.osv)
              vals['acc_number'] = _pretty_iban(vals['acc_number'])
          return super(res_partner_bank, self).write(cr, uid, ids, vals, context)
  
 +    def is_iban_valid(self, cr, uid, iban, context=None):
 +        """Check if IBAN is valid or not
 +        @param iban: IBAN as string
 +        @return: True if IBAN is valid, False if IBAN is not valid
 +        """
 +        iban = _format_iban(iban).lower()
-         if iban[:2] in _iban_len and len(iban) != _iban_len[iban[:2]]:
++        if iban[:2] in _ref_iban and len(iban) != len(_format_iban(_ref_iban[iban[:2]])):
 +            return False
 +        #the four first digits have to be shifted to the end
 +        iban = iban[4:] + iban[:4]
 +        #letters have to be transformed into numbers (a = 10, b = 11, ...)
 +        iban2 = ""
 +        for char in iban:
 +            if char.isalpha():
 +                iban2 += str(ord(char)-87)
 +            else:
 +                iban2 += char
 +        #iban is correct if modulo 97 == 1
 +        if not int(iban2) % 97 == 1:
 +            return False
 +        return True
 +
      def check_iban(self, cr, uid, ids, context=None):
          '''
          Check the IBAN number
          '''
          for bank_acc in self.browse(cr, uid, ids, context=context):
--            if bank_acc.state<>'iban':
++            if bank_acc.state != 'iban':
                  continue
 -            iban = _format_iban(bank_acc.acc_number).lower()
 -            if iban[:2] in _ref_iban and len(iban) != len(_format_iban(_ref_iban[iban[:2]])):
 -                return False
 -            #the four first digits have to be shifted to the end
 -            iban = iban[4:] + iban[:4]
 -            #letters have to be transformed into numbers (a = 10, b = 11, ...)
 -            iban2 = ""
 -            for char in iban:
 -                if char.isalpha():
 -                    iban2 += str(ord(char)-87)
 -                else:
 -                    iban2 += char
 -            #iban is correct if modulo 97 == 1
 -            if not int(iban2) % 97 == 1:
 +            if not self.is_iban_valid(cr, uid, bank_acc.acc_number, context=context):
                  return False
          return True
  
Simple merge
@@@ -31,7 -31,7 +31,7 @@@ class res_partner_bank(osv.osv)
          """Check the RIB key"""
          for bank_acc in self.browse(cr, uid, ids):
              # Ignore the accounts of type other than rib
-             if bank_acc.state <> 'rib':
 -            if bank_acc.state !='rib':
++            if bank_acc.state != 'rib':
                  continue
              # Fail if the needed values are empty of too short 
              if (not bank_acc.bank_code
                             help="The key is a number allowing to check the "
                                  "correctness of the other codes."),
      }
 -    
 -    def _construct_constraint_msg(self, cr, uid, ids, context=None):
 -        """Quote the data in the warning message"""
 -        # Only process the first id
 -        if type(ids) not in (int, long):
 -            id = ids[0]
 -        rib = self.browse(cr, uid, id, context=context)
 -        if rib:
 -            return (_("\nThe RIB key %s does not correspond to the other "
 -                        "codes: %s %s %s.") %
 -                        (rib.key, 
 -                        rib.bank_code, 
 -                        rib.office,
 -                        rib.acc_number) )
  
-     _constraints = [(_check_key, 'Error message in raise',
 -    _constraints = [(_check_key,
 -                     _construct_constraint_msg,
 -                     ["key"])]
 -    
++    _constraints = [(_check_key, 'The RIB and/or IBAN is not valid',
 +         ['rib_acc_number', 'bank_code', 'office', 'key'])]
 +
  res_partner_bank()
  
  class res_bank(osv.osv):