Okay, found a possible solution:
Both Bank Code and Account Number (BBAN) can be extracted from IBAN (see Wikipedia IBAN structure).
So I wrote a patch for base_iban.py which provides two further columns:
- bban: returns the account number extracted of the IBAN
- iban_bank_code: returns the bank code extracted of the IBAN
Usage example in RML/Webkit:
Bank: company.bank_ids[0].bank_name
Bank Code: company.bank_ids[0].iban_bank_code
Account Number: company.bank_ids[0].bban
BIC: company.bank_ids[0].bank_bic
IBAN: company.bank_ids[0].acc_number
As you see you can now extract national and international versions using only 1 bank account in OpenERP.
I hope this helps someone.
File to patch: /usr/share/pyshared/openerp/addons/base_iban/base_iban.py
Patch:
161,162d160
< 'de': lambda x: x[12:],
< 'at': lambda x: x[9:],
171,202d168
< # remove whitespace characters
< record.acc_number = record.acc_number.replace(' ','')
< res[record.id] = function(record.acc_number)
< break
< return res
<
< def get_bban_from_iban_fct(self, cr, uid, ids, name, arg, context=None):
< return self.get_bban_from_iban(cr,uid,ids,context)
<
< def get_bank_code_from_iban(self, cr, uid, ids, name, arg, context=None):
< '''
< This function returns the bank code computed from the iban
< '''
< res = {}
< mapping_list = {
< #TODO add rules for others countries
< # IBAN format taken from Wikipedia/IBAN-Structure
< # get the first 9 chars, remove the first 4 chars
< 'at': lambda x: x[4:9],
< 'de': lambda x: x[4:12],
< 'ch': lambda x: x[4:9],
< 'be': lambda x: x[4:7],
< }
< for record in self.browse(cr, uid, ids, context=context):
< if not record.acc_number:
< res[record.id] = False
< continue
< res[record.id] = False
< for code, function in mapping_list.items():
< if record.acc_number.lower().startswith(code):
< # remove whitespace characters
< record.acc_number = record.acc_number.replace(' ','')
212,213d177
< 'bban': fields.function(get_bban_from_iban_fct, type='char', size=20, string='Bank account number', invisible=True),
< 'iban_bank_code': fields.function(get_bank_code_from_iban, type='char', size=20, string='Bank account number', invisible=True)
Best regards,
Reinhard