Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[OpenERP7] base_iban: BBAN, IBAN - BIC and Bank Code with one Bank Account

By
Reinhard Schneidewind
on 6/24/13, 11:12 AM 2,419 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

0

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

0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 6/24/13, 1:06 PM

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).

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...

Reinhard Schneidewind
on 6/24/13, 1:10 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/24/13, 11:12 AM
Seen: 2419 times
Last updated: 3/16/15, 8:10 AM