[FIX] base: qweb float_time widget negative value
When trying to convert -1.5 into a time format, instead of displaying -1:30, the widget will show -2:30, which is confusing. The float time qweb widget does not handle correclty negative, when its javascript version works correclty. This commit fixes this problem.
This commit is contained in:
@@ -355,8 +355,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)
|
||||
factor = -1 if value < 0 else 1
|
||||
hours, minutes = divmod(abs(value) * 60, 60)
|
||||
return '%02d:%02d' % (hours * factor, minutes)
|
||||
|
||||
|
||||
class DurationConverter(models.AbstractModel):
|
||||
|
||||
Reference in New Issue
Block a user