Merge lp:~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements into lp:banking-addons/bank-statement-reconcile-70

Proposed by Florian da Costa
Status: Merged
Merge reported by: Florian da Costa
Merged at revision: not available
Proposed branch: lp:~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 47 lines (+11/-3)
2 files modified
account_statement_base_import/statement.py (+9/-1)
account_statement_base_import/wizard/import_statement.py (+2/-2)
To merge this branch: bzr merge lp:~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements
Reviewer Review Type Date Requested Status
Laurent Mignon (Acsone) (community) Needs Information
Joël Grand-Guillaume @ camptocamp code review, no tests Needs Fixing
Stéphane Bidoul (Acsone) (community) code review Needs Information
Nicolas Bessi - Camptocamp Pending
Yannick Vaucher @ Camptocamp Pending
Sébastien BEAU - http://www.akretion.com no test, code review Pending
Frederic Clementi - Camptocamp Pending
Guewen Baconnier @ Camptocamp Pending
Review via email: mp+209863@code.launchpad.net

This proposal supersedes a proposal from 2013-12-04.

Description of the change

Hi,
In some case like the CFONB norme (French norme) many bank statement can be extracted from the same file.
So I need to change the signature in order to always work with a list of id, than in my can I am able to inherit everything and process all of my bank statement (http://bazaar.launchpad.net/~akretion-team/+junk/account_statement_cfonb/view/head:/account_statement_cfonb/statement.py)

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : Posted in a previous version of this proposal

Hi,

Thanks for the contribs !

My opinion on that one is that I prefer letting this method "def statement_import" as it is. His purpose is to import one single statement.

Why not simply adding a new method called "def multi_statement_import" that call the first one for each instance ?

This way, you reduce the risk of breaking others work by returning a dict instead of a int/long.

For this reason, I mark it as need fixing.

Regards,

Joël

review: Needs Fixing (code review, no tests)
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote : Posted in a previous version of this proposal

Ok it's ok for me. We will propose a new solution using def multi_statement_import

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote : Posted in a previous version of this proposal

LGTM. It's ok for me. We do not change anymore the original API.

review: Approve (no test, code review)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : Posted in a previous version of this proposal

Hi,

Thanks for the changes, that looks good now !

Regards,

Joël

review: Approve (code review, no tests)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : Posted in a previous version of this proposal

Why do you pass the context in the parser?

    result_row_list = parser.parse(file_stream, context=context)

review: Needs Information
Revision history for this message
Florian da Costa (florian-dacosta) wrote : Posted in a previous version of this proposal
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : Posted in a previous version of this proposal

There are conflicts please resubmit

review: Needs Resubmitting
Revision history for this message
Florian da Costa (florian-dacosta) wrote :

Here, I re-submited it. Hope it resolves the conflicts.

Revision history for this message
Florian da Costa (florian-dacosta) wrote :

If there are no more conflicts, Is it possible to merge this mp?
Thanks

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hello,

First of all, apologies for commenting so late in the review process.

We are also looking at solutions to support multiple statements in the same file, in order to support belgian CODA files.

I have looked at your merge proposal and the cfonb parser and I'm actually a bit uneasy with the proposed mechanism which requires storing parser state in the context between calls to parse().

Would you consider a variant where the parser is created (new_bank_statement_parser) in multi_statement_import, and then having statement_import called repeatedly with the same parser instance until parser.parse returns no data?

Best regards,

review: Needs Information (code review)
Revision history for this message
Florian da Costa (florian-dacosta) wrote :

Hello,

I agree it is not ideal to do it this way, passing the parser state through the context, but the goal was not to change the statement_import function. This way we do not break anything.

Maybe we could merge it as it is for the v7 and plan to refactore the statement_import function for the v8.

Regards

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi,

I would like to propose an alternative based on the principles enunciated by Stéphane. I'm also uneasy with the proposed mechanism that requires to subclass the AccountStatementProfile class and stores the parser state in the context.

By looking in more detail in the code, I can not find overrides or other usages of the import_statement method than the one in the CreditPartnerStatementImporter wizard. Therefore, IMO, it's not a problem to change the 'statement_import' function to make the code more natural.

You can find a first draft of the proposed alternative at http://bazaar.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements/revision/147

Best regards,

lmi

review: Needs Information (code review)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

I'm in favor of Laurent's suggestion. If you would please consider his remakrs here it would be great ! Thanks a lot for your contribution here !

review: Needs Fixing (code review, no tests)
Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi Florian,

I've implemented the multi statement support in an addon to import the bank statements from a standard CODA file (belgium standard).

The implementation use the draft proposal unchanged. ( http://bazaar.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-multi-statements/revision/147)

As expected, the changes to the parser were minor and seem to take advantage of existing methods.

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

What do you think of this approach?

Regards,

lmi

review: Needs Information
Revision history for this message
Florian da Costa (florian-dacosta) wrote :

Hello Laurent,

I took a look on your mp and it seems great.
You approach is ok for me. I guess we can close this mp and merge yours!

Thanks a lot

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hello Florian,

Thanks for the review. I'll propose my branch for merging.

Regards,

lmi

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py 2014-03-06 09:40:57 +0000
+++ account_statement_base_import/statement.py 2014-03-07 08:38:37 +0000
@@ -144,6 +144,14 @@
144 vals.update(parser.get_st_vals())144 vals.update(parser.get_st_vals())
145 return vals145 return vals
146146
147
148 def multi_statement_import(self, cr, uid, ids, profile_id, file_stream,
149 ftype="csv", context=None):
150 statement_id = self.statement_import(cr, uid, ids, profile_id, file_stream,
151 ftype=ftype, context=context)
152 return [statement_id]
153
154
147 def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):155 def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
148 """156 """
149 Create a bank statement with the given profile and parser. It will fullfill the bank statement157 Create a bank statement with the given profile and parser. It will fullfill the bank statement
@@ -165,7 +173,7 @@
165 prof = prof_obj.browse(cr, uid, profile_id, context=context)173 prof = prof_obj.browse(cr, uid, profile_id, context=context)
166174
167 parser = new_bank_statement_parser(prof.import_type, ftype=ftype)175 parser = new_bank_statement_parser(prof.import_type, ftype=ftype)
168 result_row_list = parser.parse(file_stream)176 result_row_list = parser.parse(file_stream, context=context)
169 # Check all key are present in account.bank.statement.line!!177 # Check all key are present in account.bank.statement.line!!
170 if not result_row_list:178 if not result_row_list:
171 raise osv.except_osv(_("Nothing to import"),179 raise osv.except_osv(_("Nothing to import"),
172180
=== modified file 'account_statement_base_import/wizard/import_statement.py'
--- account_statement_base_import/wizard/import_statement.py 2013-12-04 14:10:49 +0000
+++ account_statement_base_import/wizard/import_statement.py 2014-03-07 08:38:37 +0000
@@ -99,7 +99,7 @@
99 ftype = self._check_extension(importer.file_name)99 ftype = self._check_extension(importer.file_name)
100 context['file_name'] = importer.file_name100 context['file_name'] = importer.file_name
101 sid = self.pool.get(101 sid = self.pool.get(
102 'account.statement.profile').statement_import(102 'account.statement.profile').multi_statement_import(
103 cr,103 cr,
104 uid,104 uid,
105 False,105 False,
@@ -112,5 +112,5 @@
112 action_obj = self.pool.get('ir.actions.act_window')112 action_obj = self.pool.get('ir.actions.act_window')
113 action_id = model_obj.get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')[1]113 action_id = model_obj.get_object_reference(cr, uid, 'account', 'action_bank_statement_tree')[1]
114 res = action_obj.read(cr, uid, action_id)114 res = action_obj.read(cr, uid, action_id)
115 res['domain'] = res['domain'][:-1] + ",('id', '=', %d)]" % sid115 res['domain'] = res['domain'][:-1] + ",('id', 'in', %s)]" % sid
116 return res116 return res

Subscribers

People subscribed via source and target branches