[ADD]Comments

bzr revid: dle@openerp.com-20121218104532-jvugb4cm2g1w90g8
This commit is contained in:
dle@openerp.com 2012-12-18 11:45:32 +01:00
parent 4a07e497da
commit 9041fb2c05
1 changed files with 16 additions and 2 deletions

View File

@ -91,10 +91,24 @@ class account_coda_import(osv.osv_memory):
raise osv.except_osv(_('Error') + ' R1003', _('Unsupported bank account structure '))
statement['journal_id'] = False
statement['bank_account'] = False
"""
Belgian Account Numbers are composed of 12 digits.
In OpenERP, the user can fill the bank number in any format: With or without IBan code, with or without spaces, with or without '-'
The two following sql requests handle those cases.
"""
if len(statement['acc_number']) >= 12:
cr.execute("select id from res_partner_bank where replace(acc_number,' ','') like %s", ('%' + statement['acc_number'] + '%',))
"""
If the Account Number is >= 12 digits, it is mostlikely a Belgian Account Number (With or without IBAN).
The following request try to find the Account Number using a 'like' operator.
So, if the Account Number is stored with IBAN code, it can be found thanks to this.
"""
cr.execute("select id from res_partner_bank where replace('-','',replace(acc_number,' ','')) like %s", ('%' + statement['acc_number'] + '%',))
else:
cr.execute("select id from res_partner_bank where replace(acc_number,' ','') = %s", (statement['acc_number'],))
"""
This case is necessary to avoid cases like the Account Number in the CODA file is set to a single or few digits,
and so a 'like' operator would return the first account number in the database which matches.
"""
cr.execute("select id from res_partner_bank where replace('-','',replace(acc_number,' ','')) = %s", (statement['acc_number'],))
bank_ids = [id[0] for id in cr.fetchall()]
if bank_ids and len(bank_ids) > 0:
bank_accs = self.pool.get('res.partner.bank').browse(cr, uid, bank_ids)