[FIX] base: float_time

- Record a timesheet entry of '00:14'
  => it is correctly saved as 0.23333...
- Select the entry, and print 'Timesheet Entries'

The tmesheet appears as '00:13'.

This is because `minutes` is equal to `13.99999999999998`, which is
truncated to `13` at formatting.

A simple call to `round` is enough to prevent this. Moreover, we add a
check to convert 60 minutes into an hour. This is similar to:

https://github.com/odoo/odoo/blob/a73206c0b1b1519aef4e7f11d83b6a2fc31eca47/addons/web/static/src/js/fields/field_utils.js#L205-L218

opw-1969149

closes odoo/odoo#32834

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2019-04-23 11:51:21 +00:00
parent b71b78035b
commit 7e312c34f7
+4
View File
@@ -370,6 +370,10 @@ class FloatTimeConverter(models.AbstractModel):
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)