From 93e93e8d4e785ca2786dc86ea88806a2452d0e4f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 9 Sep 2013 14:57:51 +0200 Subject: [PATCH] [IMP] account: don't write state as draft on lines that are already in draft state (performace improvement) bzr revid: mat@openerp.com-20130909125751-we5n8e018bwqadvz --- addons/account/account.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index e48a20388bb..da2a74f5353 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1654,9 +1654,11 @@ class account_move(osv.osv): else: # We can't validate it (it's unbalanced) # Setting the lines as draft - obj_move_line.write(cr, uid, line_ids, { - 'state': 'draft' - }, context, check=False) + not_draft_line_ids = list(set(line_ids) - set(line_draft_ids)) + if not_draft_line_ids: + obj_move_line.write(cr, uid, not_draft_line_ids, { + 'state': 'draft' + }, context, check=False) # Create analytic lines for the valid moves for record in valid_moves: obj_move_line.create_analytic_lines(cr, uid, [line.id for line in record.line_id], context)