← Back to team overview

banking-addons-team team mailing list archive

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

 

Florian da Costa has proposed merging lp:~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements into lp:banking-addons/bank-statement-reconcile-7.0.

Requested reviews:
  Guewen Baconnier @ Camptocamp (gbaconnier-c2c)
  Frederic Clementi - Camptocamp (frederic-clementi)
  Sébastien BEAU - http://www.akretion.com (sebastien.beau): no test, code review
  Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c): code review, no tests
  Yannick Vaucher @ Camptocamp (yvaucher-c2c)
  Nicolas Bessi - Camptocamp (nbessi-c2c)

For more details, see:
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements/+merge/209863

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)

-- 
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-multi-statements/+merge/209863
Your team Banking Addons Core Editors is subscribed to branch lp:banking-addons/bank-statement-reconcile-7.0.
=== 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 @@
         vals.update(parser.get_st_vals())
         return vals
 
+
+    def multi_statement_import(self, cr, uid, ids, profile_id, file_stream,
+                               ftype="csv", context=None):
+        statement_id = self.statement_import(cr, uid, ids, profile_id, file_stream,
+                                             ftype=ftype, context=context)
+        return [statement_id]
+
+
     def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
         """
         Create a bank statement with the given profile and parser. It will fullfill the bank statement
@@ -165,7 +173,7 @@
         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.parse(file_stream, context=context)
         # 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	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 @@
         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