Skip to Content
Menu
This question has been flagged
2 Replies
15684 Views

Hi,

I'd like to show both IBAN and BBAN (national account number) on invoices using a single bank account. So I've modified base_iban.py to add another column which provides me the BBAN. Therefore base_iban.py provides a method "get_bban_from_iban" which I've used:

161,162d160
<           'de': lambda x: x[12:],

<           'at': lambda x: x[9:],
175,177d172
<     def get_bban_from_iban_fct(self, cr, uid, ids, name, arg, context=None):
<       return self.get_bban_from_iban(cr,uid,ids,context)
< 
183d177
<       'bban': fields.function(get_bban_from_iban_fct, type='char', size=20, string='Bank account number', invisible=True)

Is there a simple way to call the method directly from the report without adding a new column?

The next thing is the BIC . Has anyone a solution to provide both BIC and bank code in OpenERP7 using a single bank account? I expect that an additional field for bank code entry would be needed.

Thanks,

Reinhard

Avatar
Discard
Author Best Answer

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

Avatar
Discard
Best Answer

Why not adding additional fields on your invoice (rml-file), and print the needed fields directly? Or you can just type the IBAN/BIC/BBAN as fixed numbers (unless the same invoice is used for different companies).

Avatar
Discard
Author

Hi, thanks for your answer. The problem is that for an invoice the bank account can be specified and I want to use this. So if I use separate BBAN/IBAN accounts it would be hard to find the corresponding IBAN account to a BBAN account.

But I think I've found a way to handle this. The bank code is part of the IBAN. So I can extract it with another method. I will extract it and provide a patch for those who are interested in doing it the same way...

Related Posts Replies Views Activity
3
Dec 23
1444
2
Sep 16
3103
0
Jun 15
3256
3
Mar 19
9047