[FIX] set state to done when no no lines are generated on selected policies

(lp:c2c-addons/6.1  rev 89.1.28)
This commit is contained in:
Guewen Baconnier @ Camptocamp
2012-10-26 10:08:53 +02:00
parent 0a15f5bf5c
commit f7d40f64eb
2 changed files with 6 additions and 3 deletions

View File

@@ -111,6 +111,8 @@ class CreditControlRun(Model):
try:
lines = policy._get_moves_line_to_process(run.date, context=context)
tmp_manual = policy._check_lines_policies(lines, context=context)
# FIXME why do not use only sets instead of converting them each
# time ?
lines = list(set(lines) - set(tmp_manual))
manually_managed_lines += tmp_manual
if not lines:
@@ -139,13 +141,14 @@ class CreditControlRun(Model):
context=context)
return False
vals = {'report': u"Number of generated lines : %s \n" % (len(credit_line_ids),),
'state': 'done',
'manual_ids': [(6, 0, manually_managed_lines)]}
if errors:
vals['report'] += u"Following line generation errors appends:"
vals['report'] += u"----\n".join(errors)
vals['state'] = 'done'
run.write(vals, context=context)
run.write({'state': 'done'}, context=context)
# lines will correspond to line that where not treated
return lines