From: Alexis de Lattre Date: Tue, 31 Jan 2012 13:36:57 +0000 (+0100) Subject: [MERGE] with addons-trunk and resolve conflict in base_iban X-Git-Tag: 6.1.0-web~115^2~2^2 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=c646827762174c5a1ca7a22c35a7178d3a9e9ef6;p=odoo%2Fodoo.git [MERGE] with addons-trunk and resolve conflict in base_iban <> changed to != Changed error message bzr revid: alexis@via.ecp.fr-20120131133657-0gzkk0bcb709ca6f --- c646827762174c5a1ca7a22c35a7178d3a9e9ef6 diff --cc addons/base_iban/base_iban.py index d99d07f,4519271..80033f8 --- a/addons/base_iban/base_iban.py +++ b/addons/base_iban/base_iban.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 diff --cc addons/l10n_fr_rib/bank.py index b6ae2a0,03f71f6..25b2340 --- a/addons/l10n_fr_rib/bank.py +++ b/addons/l10n_fr_rib/bank.py @@@ -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 @@@ -82,10 -72,25 +82,10 @@@ 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):