← Back to team overview

banking-addons-team team mailing list archive

Re: lp:~camptocamp/banking-addons/bank-statement-reconcile-70-fix-completion-error-message into lp:banking-addons/bank-statement-reconcile-70

 

Review: Needs Fixing code review, no test

I suggest changing the code of button_auto_completion in the following way:

* change msg from string to a list of strings for efficient appending
* reinit the msg_list for each id of the outer loop


=== modified file 'account_statement_base_completion/statement.py'
--- account_statement_base_completion/statement.py      2013-01-28 12:56:53 +0000
+++ account_statement_base_completion/statement.py      2013-01-30 09:55:41 +0000
@@ -432,9 +432,9 @@
         if context is None:
             context = {}
         stat_line_obj = self.pool.get('account.bank.statement.line')
-        msg = ""
         compl_lines = 0
         for stat in self.browse(cr, uid, ids, context=context):
+            msg_lines = []
             ctx = context.copy()
             for line in stat.line_ids:
                 res = {}
@@ -444,14 +444,15 @@
                     if res:
                         compl_lines += 1
                 except ErrorTooManyPartner, exc:
-                    msg += repr(exc) + "\n"
+                    msg_lines.append(repr(exc))
                 except Exception, exc:
-                    msg += repr(exc) + "\n"
+                    msg_lines.append(repr(exc))
                 # vals = res and res.keys() or False
                 if res:
                     vals = res[line.id]
                     vals['already_completed'] = True
                     stat_line_obj.write(cr, uid, [line.id], vals, context=ctx)
-            self.write_completion_log(
-                    cr, uid, stat.id, msg, compl_lines, context=context)
+            msg = u'\n'.join(msg_lines)
+            self.write_completion_log(cr, uid, stat.id,
+                                  msg, compl_lines, context=context)
         return True



-- 
https://code.launchpad.net/~camptocamp/banking-addons/bank-statement-reconcile-70-fix-completion-error-message/+merge/145146
Your team Banking Addons Team is subscribed to branch lp:banking-addons/bank-statement-reconcile-70.


References