Skip to content
Permalink
Browse files

[FIX] base: value_to_html doens't keep the minus sign for times betwe…

…en 0 and 1

- Install timesheets and studio.
- In timesheets add a time of -0.5 (minus half an hour).
- Enter studio
- Switch to the Reports tab, and click Timesheet Entries.

Before this commit:

The time is displayed as 00:30.

After this commit:

The time is displayed as -00:30.

OPW: 2036188
  • Loading branch information...
Florimond committed Oct 9, 2019
1 parent c6f1f05 commit eaf6841f327b2496e6e9f55fcd7900af79a8bde9
Showing with 3 additions and 3 deletions.
  1. +3 −3 odoo/addons/base/ir/ir_qweb/fields.py
@@ -368,14 +368,14 @@ class FloatTimeConverter(models.AbstractModel):

@api.model
def value_to_html(self, value, options):
sign = math.copysign(1.0, value)
hours, minutes = divmod(abs(value) * 60, 60)
minutes = round(minutes)
if minutes == 60:
minutes = 0
hours += 1
return '%02d:%02d' % (sign * hours, minutes)

if value < 0:
return '-%02d:%02d' % (hours, minutes)
return '%02d:%02d' % (hours, minutes)

class DurationConverter(models.AbstractModel):
""" ``duration`` converter, to display integral or fractional values as

0 comments on commit eaf6841

Please sign in to comment.
You can’t perform that action at this time.