[FIX] poor satement write function performance

This commit is contained in:
unknown
2013-04-12 10:24:11 +02:00
parent ee6e88adc1
commit a828f2527a

View File

@@ -18,11 +18,27 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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