Fix infinite loop in easy_reconcile

This commit is contained in:
Florian
2015-02-23 11:42:22 +01:00
committed by florian-dacosta
parent 7e699d50db
commit 85f548e4d3

View File

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