From 60c94c7c423d8d4232b0f4e402a1a3723ad6253c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 30 Jun 2015 15:42:24 +0200 Subject: [PATCH] [FIX] project: Working Time Progress The precision of the field 'hours' in project.task.work and the precision of 'remaining_hours' are not the same. This is why the difference between them can generate some very small negative difference which implies an infinite percentage for the working progress time. opw:643649 --- addons/project/project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/project/project.py b/addons/project/project.py index a6ca9bc17a1..05e68afbdd3 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -27,6 +27,7 @@ from openerp import SUPERUSER_ID from openerp import tools from openerp.addons.resource.faces import task as Task from openerp.osv import fields, osv +from openerp.tools import float_is_zero from openerp.tools.translate import _ @@ -658,7 +659,7 @@ class task(osv.osv): res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': (task.remaining_hours or 0.0) + hours.get(task.id, 0.0)} res[task.id]['delay_hours'] = res[task.id]['total_hours'] - task.planned_hours res[task.id]['progress'] = 0.0 - if (task.remaining_hours + hours.get(task.id, 0.0)): + if not float_is_zero(res[task.id]['total_hours'], precision_digits=2): res[task.id]['progress'] = round(min(100.0 * hours.get(task.id, 0.0) / res[task.id]['total_hours'], 99.99),2) if task.stage_id and task.stage_id.fold: res[task.id]['progress'] = 100.0