From 971ffa3db10d23108873446a06d7eb848c9512dd Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 14 Aug 2014 15:46:37 +0200 Subject: [PATCH] [FIX] account: reconcile: no useless revalidation Avoid revalidating the complete account moves that contain the lines being reconciled. The reconciliation does not change the validity of those moves anyway. This represents a very important speed up of reconciliation when moves with several hundred lines are involved. --- addons/account/account.py | 3 ++- addons/account/account_move_line.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index a42bab8e7f5..a12b5bd1052 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1682,7 +1682,8 @@ class account_move_reconcile(osv.osv): if not total: self.pool.get('account.move.line').write(cr, uid, map(lambda x: x.id, rec.line_partial_ids), - {'reconcile_id': rec.id } + {'reconcile_id': rec.id }, + context=context ) return True diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index b3f21eb1525..cf14d465f47 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -803,11 +803,14 @@ class account_move_line(osv.osv): if self.pool.get('res.currency').is_zero(cr, uid, currency_id, total): res = self.reconcile(cr, uid, merges+unmerge, context=context, writeoff_acc_id=writeoff_acc_id, writeoff_period_id=writeoff_period_id, writeoff_journal_id=writeoff_journal_id) return res + # marking the lines as reconciled does not change their validity, so there is no need + # to revalidate their moves completely. + reconcile_context = dict(context, novalidate=True) r_id = move_rec_obj.create(cr, uid, { 'type': type, 'line_partial_ids': map(lambda x: (4,x,False), merges+unmerge) - }, context=context) - move_rec_obj.reconcile_partial_check(cr, uid, [r_id] + merges_rec, context=context) + }, context=reconcile_context) + move_rec_obj.reconcile_partial_check(cr, uid, [r_id] + merges_rec, context=reconcile_context) return True def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context=None): @@ -932,11 +935,14 @@ class account_move_line(osv.osv): writeoff_line_ids = [writeoff_line_ids[1]] ids += writeoff_line_ids + # marking the lines as reconciled does not change their validity, so there is no need + # to revalidate their moves completely. + reconcile_context = dict(context, novalidate=True) r_id = move_rec_obj.create(cr, uid, { 'type': type, 'line_id': map(lambda x: (4, x, False), ids), 'line_partial_ids': map(lambda x: (3, x, False), ids) - }) + }, context=reconcile_context) wf_service = netsvc.LocalService("workflow") # the id of the move.reconcile is written in the move.line (self) by the create method above # because of the way the line_id are defined: (4, x, False)