Community mailing list archives

community@mail.odoo.com

Odoo 9 - Import Statement API Issue

by
Jerome Sonnet
- 09/27/2015 06:02:25
Hello,

I am trying to implement a bank statement import module for Odoo 9 and it seems to me the code is incoherent

When you read the doc in _parse_file and compare it to the code in _check_parsed_data it does not match, the structure described and the check done is not coherent.

Any thought ?

I can definitively get it working but the API is unclear. Having the possibility to import one file with many account number is also a feature I would like to see sometime.

Cheers,

Jerome

def _parse_file(self, data_file):
""" Each module adding a file support must extends this method. It processes the file if it can, returns super otherwise, resulting in a chain of responsability.
This method parses the given file and returns the data required by the bank statement import process, as specified below.
rtype: triplet (if a value can't be retrieved, use None)
- currency code: string (e.g: 'EUR')
The ISO 4217 currency code, case insensitive
- account number: string (e.g: 'BE1234567890')
The number of the bank account which the statement belongs to
- bank statements data: list of dict containing (optional items marked by o) :
- 'name': string (e.g: '000000123')
- 'date': date (e.g: 2013-06-26)
-o 'balance_start': float (e.g: 8368.56)
-o 'balance_end_real': float (e.g: 8888.88)
- 'transactions': list of dict containing :
- 'name': string (e.g: 'KBC-INVESTERINGSKREDIET 787-5562831-01')
- 'date': date
- 'amount': float
- 'unique_import_id': string
-o 'account_number': string
Will be used to find/create the res.partner.bank in odoo
-o 'note': string
-o 'partner_name': string
-o 'ref': string
"""
raise UserError(_('Could not make sense of the given file.\nDid you install the module to support this type of file ?'))
def _check_parsed_data(self, stmts_vals):
""" Basic and structural verifications """
if len(stmts_vals) == 0:
raise UserError(_('This file doesn\'t contain any statement.'))
no_st_line = True
for vals in stmts_vals:
if vals['transactions'] and len(vals['transactions']) > 0:
no_st_line = False
break
if no_st_line:
raise UserError(_('This file doesn\'t contain any transaction.'))