~camptocamp/banking-addons/bank-statement-reconcile_vre

« back to all changes in this revision

Viewing changes to account_statement_base_import/statement.py

[MRG] Improve statement import wizard by using mass writing of statement line in order to avoid store field loop computation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
        try:
172
172
            # Record every line in the bank statement and compute the global commission
173
173
            # based on the commission_amount column
 
174
            statement_store = []
174
175
            for line in result_row_list:
175
176
                parser_vals = parser.get_st_line_vals(line)
176
177
                values = self.prepare_statetement_lines_vals(
177
178
                        cr, uid, parser_vals, account_payable,
178
179
                        account_receivable, statement_id, context)
179
180
                # we finally create the line in system
180
 
                statement_line_obj.create(cr, uid, values, context=context)
 
181
                statement_store.append((0, 0, values))
181
182
            # Build and create the global commission line for the whole statement
182
 
            comm_vals = self.prepare_global_commission_line_vals(
183
 
                    cr, uid, parser, result_row_list, prof, statement_id, context)
 
183
            statement_obj.write(cr, uid, [statement_id],
 
184
                                {'line_ids': statement_store}, context=context)
 
185
            comm_vals = self.prepare_global_commission_line_vals(cr, uid, parser, result_row_list,
 
186
                                                                 prof, statement_id, context)
184
187
            if comm_vals:
185
188
                statement_line_obj.create(cr, uid, comm_vals, context=context)
186
189