[FIX] next report date and isoformat

bzr revid: mat@openerp.com-20130313104900-5h306omqclwfgqmi
This commit is contained in:
Martin Trigaux 2013-03-13 11:49:00 +01:00
parent 25d6dc30a8
commit eeb6d2ea0b
1 changed files with 6 additions and 3 deletions

View File

@ -76,12 +76,15 @@ class gamification_goal_plan(osv.Model):
for plan in self.browse(cr, uid, ids, context):
last = datetime.strptime(plan.last_report_date, '%Y-%m-%d').date()
if plan.report_message_frequency == 'daily':
res[plan.id] = last + timedelta(days=1).isoformat()
next = last + timedelta(days=1)
res[plan.id] = next.isoformat()
elif plan.report_message_frequency == 'weekly':
res[plan.id] = last + timedelta(days=7).isoformat()
next = last + timedelta(days=7)
res[plan.id] = next.isoformat()
elif plan.report_message_frequency == 'monthly':
month_range = calendar.monthrange(last.year, last.month)
res[plan.id] = last.replace(day=month_range[1]) + timedelta(days=1).isoformat()
next = last.replace(day=month_range[1]) + timedelta(days=1)
res[plan.id] = next.isoformat()
elif plan.report_message_frequency == 'yearly':
res[plan.id] = last.replace(year=last.year + 1).isoformat()
else: # frequency == 'once':