[FIX] resource: avoid floating point error in interval

bzr revid: mat@openerp.com-20130507094035-rtbyzukv4shpx024
This commit is contained in:
Martin Trigaux
2013-05-07 11:40:35 +02:00
parent 966631d383
commit 22d6ef5cfe
+4 -2
View File
@@ -128,7 +128,8 @@ class resource_calendar(osv.osv):
d2 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60))
result.append((d1, d2))
current_hour = hour_from
todo -= (m-hour_from)
# avoid float point error with round
todo = round(todo - (hour_to - m), 4)
dt_from -= timedelta(days=1)
current_hour = 24
maxrecur -= 1
@@ -180,7 +181,8 @@ class resource_calendar(osv.osv):
d2 = datetime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60))
result.append((d1, d2))
current_hour = hour_to
todo -= (hour_to - m)
# avoid float point error with round
todo = round(todo - (hour_to - m), 4)
dt_from += timedelta(days=1)
current_hour = 0
maxrecur -= 1