From 44ea58234ec0d902ddf0caf7aefb367acc013627 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 27 Jul 2018 16:04:21 +0200 Subject: [PATCH] [FIX] base, hr_timesheet: display negative float_time values Before this commit, negative values in a float field interpreted as time (i.e. unit_amount on analytic lines) were wrongly formatted After this commit, not only we correct the hr_timesheet qweb templates but we also correct the qweb widget to handle the case OPW 1869986 closes #26024 --- addons/hr_timesheet/report/report_timesheet_templates.xml | 6 ++++-- odoo/addons/base/ir/ir_qweb/fields.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/hr_timesheet/report/report_timesheet_templates.xml b/addons/hr_timesheet/report/report_timesheet_templates.xml index fea714a5d7a..dbc0ad4a583 100644 --- a/addons/hr_timesheet/report/report_timesheet_templates.xml +++ b/addons/hr_timesheet/report/report_timesheet_templates.xml @@ -44,7 +44,7 @@ - + @@ -53,7 +53,9 @@ Total - + + + diff --git a/odoo/addons/base/ir/ir_qweb/fields.py b/odoo/addons/base/ir/ir_qweb/fields.py index 69cb3631e5d..5a9000598de 100644 --- a/odoo/addons/base/ir/ir_qweb/fields.py +++ b/odoo/addons/base/ir/ir_qweb/fields.py @@ -7,6 +7,7 @@ from odoo import api, fields, models, _ from PIL import Image import babel from lxml import etree +import math from odoo.tools import html_escape as escape, posix_to_ldml, safe_eval, float_utils, format_date, pycompat @@ -367,8 +368,9 @@ class FloatTimeConverter(models.AbstractModel): @api.model def value_to_html(self, value, options): - hours, minutes = divmod(value * 60, 60) - return '%02d:%02d' % (hours, minutes) + sign = math.copysign(1.0, value) + hours, minutes = divmod(abs(value) * 60, 60) + return '%02d:%02d' % (sign * hours, minutes) class DurationConverter(models.AbstractModel):