From 22d6ef5cfe77aba62a9b7586b544180ec66d418b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 7 May 2013 11:40:35 +0200 Subject: [PATCH] [FIX] resource: avoid floating point error in interval bzr revid: mat@openerp.com-20130507094035-rtbyzukv4shpx024 --- addons/resource/resource.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 73a6e2a3ec8..a37d8ca89fe 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -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