[FIX] rounding of float_time to the next hour should bump the hour, nor display 60mn

bzr revid: xmo@openerp.com-20130123101557-v63oxes2emrwcz19
This commit is contained in:
Xavier Morel 2013-01-23 11:15:57 +01:00
commit ca038643b9
2 changed files with 13 additions and 3 deletions

View File

@ -166,9 +166,13 @@ instance.web.format_value = function (value, descriptor, value_if_empty) {
value = Math.abs(value);
pattern = '-' + pattern;
}
return _.str.sprintf(pattern,
Math.floor(value),
Math.round((value % 1) * 60));
var hour = Math.floor(value);
var min = Math.round((value % 1) * 60);
if (min == 60){
min = 0;
hour = hour + 1;
}
return _.str.sprintf(pattern, hour, min);
case 'many2one':
// name_get value format
return value[1] ? value[1].split("\n")[0] : value[1];

View File

@ -68,6 +68,12 @@ openerp.testing.section('web-formats', {
strictEqual(
instance.web.format_value(-0.0085, {type:'float', widget:'float_time'}),
'-00:01');
strictEqual(
instance.web.format_value(4.9999, {type:'float', widget:'float_time'}),
'05:00');
strictEqual(
instance.web.format_value(-6.9999, {type:'float', widget:'float_time'}),
'-07:00');
});
test("format_float", function (instance) {
var fl = 12.1234;