banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #01958
[Merge] lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements into lp:banking-addons/bank-statement-reconcile-7.0
Laurent Mignon (Acsone) has proposed merging lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements into lp:banking-addons/bank-statement-reconcile-7.0.
Requested reviews:
Banking Addons Core Editors (banking-addons-team)
For more details, see:
https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements/+merge/219683
Following the review process of the first merge proposal for the same functionality from Florian da Costa from Akretion (https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements/+merge/209863), here is some changes to support the import of multiple statements at once.
This branch is used to support the import of multiple statements from a standard CODA file (belgium standard).
http://bazaar.launchpad.net/~acsone-openerp/+junk/coda-completion/revision/14
http://bazaar.launchpad.net/~acsone-openerp/+junk/coda-completion/view/head:/account_statement_coda_import/parser/coda_file_parser.py
Thank you to Florian for its first proposal!
--
https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements/+merge/219683
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements into lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_base_import/parser/parser.py'
--- account_statement_base_import/parser/parser.py 2014-05-14 15:45:12 +0000
+++ account_statement_base_import/parser/parser.py 2014-05-15 11:27:15 +0000
@@ -54,6 +54,7 @@
self.balance_end = None
self.statement_name = None
self.statement_date = None
+ self.support_multi_statements = False
@classmethod
def parser_for(cls, parser_name):
@@ -163,10 +164,16 @@
raise Exception(_('No buffer file given.'))
self._format(*args, **kwargs)
self._pre(*args, **kwargs)
- self._parse(*args, **kwargs)
- self._validate(*args, **kwargs)
- self._post(*args, **kwargs)
- return self.result_row_list
+ if self.support_multi_statements:
+ while self._parse(*args, **kwargs):
+ self._validate(*args, **kwargs)
+ self._post(*args, **kwargs)
+ yield self.result_row_list
+ else:
+ self._parse(*args, **kwargs)
+ self._validate(*args, **kwargs)
+ self._post(*args, **kwargs)
+ yield self.result_row_list
def itersubclasses(cls, _seen=None):
=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py 2014-05-14 15:45:12 +0000
+++ account_statement_base_import/statement.py 2014-05-15 11:27:15 +0000
@@ -136,13 +136,29 @@
vals.update(parser.get_st_vals())
return vals
- def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
+ def multi_statement_import(self, cr, uid, ids, profile_id, file_stream,
+ ftype="csv", context=None):
+ prof_obj = self.pool.get("account.statement.profile")
+ if not profile_id:
+ raise osv.except_osv(_("No Profile!"),
+ _("You must provide a valid profile to import a bank statement!"))
+ prof = prof_obj.browse(cr, uid, profile_id, context=context)
+
+ parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
+ res = []
+ for result_row_list in parser.parse(file_stream):
+ statement_id = self._statement_import(cr, uid, ids, prof, parser, file_stream, ftype=ftype, context=context)
+ res.append(statement_id)
+ return res
+
+ def _statement_import(self, cr, uid, ids, prof, parser, file_stream, ftype="csv", context=None):
"""
Create a bank statement with the given profile and parser. It will fullfill the bank statement
with the values of the file providen, but will not complete data (like finding the partner, or
the right account). This will be done in a second step with the completion rules.
- :param int/long profile_id: ID of the profile used to import the file
+ :param profile : The profile used to import the file
+ :param parser: the parser
:param filebuffer file_stream: binary of the providen file
:param char: ftype represent the file exstension (csv by default)
:return: ID of the created account.bank.statemênt
@@ -150,14 +166,8 @@
statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
attachment_obj = self.pool.get('ir.attachment')
- prof_obj = self.pool.get("account.statement.profile")
- if not profile_id:
- raise osv.except_osv(_("No Profile!"),
- _("You must provide a valid profile to import a bank statement!"))
- prof = prof_obj.browse(cr, uid, profile_id, context=context)
- parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
- result_row_list = parser.parse(file_stream)
+ result_row_list = parser.result_row_list
# Check all key are present in account.bank.statement.line!!
if not result_row_list:
raise osv.except_osv(_("Nothing to import"),
=== modified file 'account_statement_base_import/wizard/import_statement.py'
--- account_statement_base_import/wizard/import_statement.py 2014-02-02 09:37:44 +0000
+++ account_statement_base_import/wizard/import_statement.py 2014-05-15 11:27:15 +0000
@@ -99,7 +99,7 @@
ftype = self._check_extension(importer.file_name)
context['file_name'] = importer.file_name
sid = self.pool.get(
- 'account.statement.profile').statement_import(
+ 'account.statement.profile').multi_statement_import(
cr,
uid,
False,
@@ -112,5 +112,5 @@
action_obj = self.pool.get('ir.actions.act_window')
action_id = model_obj.get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')[1]
res = action_obj.read(cr, uid, action_id)
- res['domain'] = res['domain'][:-1] + ",('id', '=', %d)]" % sid
+ res['domain'] = res['domain'][:-1] + ",('id', 'in', %s)]" % sid
return res
Follow ups