From a828f2527afe5ca88fc20042835c38aa358f691c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Apr 2013 10:24:11 +0200 Subject: [PATCH] [FIX] poor satement write function performance --- account_statement_ext/statement.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index a6867216..71f8f4b9 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -18,11 +18,27 @@ # along with this program. If not, see . # ############################################################################## +import openerp.addons.account.account_bank_statement as stat_mod from openerp.osv.orm import Model from openerp.osv import fields, osv from openerp.tools.translate import _ +# Monkey patch to fix bad write implementation... +def fixed_write(self, cr, uid, ids, vals, context=None): + """ Fix performance desing of original function + Ideally we should use a real postgres sequence or serial fields. + Will do it when I have time.""" + res = super(stat_mod.account_bank_statement, self).write(cr, uid, ids, + vals, context=context) + for s_id in ids: + cr.execute("UPDATE account_bank_statement_line" + " SET sequence = account_bank_statement_line.id + 1" + " where statement_id = %s", (s_id,)) + return res +stat_mod.account_bank_statement.write = fixed_write + + class AccountStatementProfil(Model): """ A Profile will contain all infos related to the type of