[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
This commit is contained in:
Goffin Simon 2015-06-30 15:42:24 +02:00
parent 01e4b76f65
commit 60c94c7c42
1 changed files with 2 additions and 1 deletions

View File

@ -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