From c4a1f50e50ac0bdbd858db640d0d76b02ffc3944 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 18 Jul 2014 15:59:19 +0200 Subject: [PATCH] Reconcile optimization: avoid to do a partial reconcile if it was already reconciled with the same lines Before this optimization, the same partial reconciliation were created at each run of the automatic reconcile. --- account_easy_reconcile/base_reconciliation.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 6145720a..7920a242 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -71,6 +71,7 @@ class EasyReconcileBase(orm.AbstractModel): 'name', 'partner_id', 'account_id', + 'reconcile_partial_id', 'move_id') return ["account_move_line.%s" % col for col in aml_cols] @@ -195,6 +196,19 @@ class EasyReconcileBase(orm.AbstractModel): context=rec_ctx) return True, True elif allow_partial: + # Check if the group of move lines was already partially + # reconciled and if all the lines were the same, in such + # case, just skip the group and consider it as partially + # reconciled (no change). + existing_partial_id = lines[0]['reconcile_partial_id'] + if existing_partial_id: + partial_line_ids = set(ml_obj.search( + cr, uid, + [('reconcile_partial_id', '=', existing_partial_id)], + context=context)) + if set(line_ids) == partial_line_ids: + return True, False + ml_obj.reconcile_partial( cr, uid, line_ids,