diff --git a/account_easy_reconcile/simple_reconciliation.py b/account_easy_reconcile/simple_reconciliation.py index 02ef74c5..6659526a 100644 --- a/account_easy_reconcile/simple_reconciliation.py +++ b/account_easy_reconcile/simple_reconciliation.py @@ -37,6 +37,7 @@ class EasyReconcileSimple(AbstractModel): if self._key_field is None: raise ValueError("_key_field has to be defined") count = 0 + commit_count = 0 res = [] while (count < len(lines)): for i in xrange(count + 1, len(lines)): @@ -57,16 +58,17 @@ class EasyReconcileSimple(AbstractModel): cr, uid, rec, [credit_line, debit_line], allow_partial=False, context=context) if reconciled: + commit_count += 1 res += [credit_line['id'], debit_line['id']] del lines[i] - count += 1 if (context['commit_every'] and - count % context['commit_every'] == 0): + commit_count % context['commit_every'] == 0): cr.commit() _logger.info( "Commit the reconciliations after %d lines", count) break + count += 1 return res, [] # empty list for partial, only full rec in "simple" rec def _simple_order(self, rec, *args, **kwargs):