From 1b3f0488405987fd3e2c541b252369b8840d39ce Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Feb 2013 16:24:40 +0100 Subject: [PATCH] [IMP] mass writing of statement line in order to avoid store field chain computation --- account_statement_base_import/statement.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index 228a37dd..5fde950f 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -26,6 +26,8 @@ from openerp.osv import fields, osv from parser import new_bank_statement_parser import sys import traceback +import profile +import time class AccountStatementProfil(Model): @@ -171,16 +173,19 @@ class AccountStatementProfil(Model): try: # Record every line in the bank statement and compute the global commission # based on the commission_amount column + statement_store = [] for line in result_row_list: parser_vals = parser.get_st_line_vals(line) values = self.prepare_statetement_lines_vals( cr, uid, parser_vals, account_payable, account_receivable, statement_id, context) # we finally create the line in system - statement_line_obj.create(cr, uid, values, context=context) + statement_store.append((0, 0, values)) # Build and create the global commission line for the whole statement - comm_vals = self.prepare_global_commission_line_vals( - cr, uid, parser, result_row_list, prof, statement_id, context) + statement_obj.write(cr, uid, [statement_id], + {'line_ids': statement_store}, context=context) + comm_vals = self.prepare_global_commission_line_vals(cr, uid, parser, result_row_list, + prof, statement_id, context) if comm_vals: statement_line_obj.create(cr, uid, comm_vals, context=context)