Skip to content
Snippets Groups Projects
Commit 9cc53150 authored by Xavier Morel's avatar Xavier Morel
Browse files

[FIX] formatting of float_time fields

lp bug: https://launchpad.net/bugs/928220 fixed

bzr revid: xmo@openerp.com-20120208135655-79qnr5tl6admxr1e
parent 301afd4b
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,12 @@ openerp.web.format_value = function (value, descriptor, value_if_empty) {
formatted[0] = openerp.web.insert_thousand_seps(formatted[0]);
return formatted.join(l10n.decimal_point);
case 'float_time':
return _.str.sprintf("%02d:%02d",
var pattern = '%02d:%02d';
if (value < 0) {
value = Math.abs(value);
pattern = '-' + pattern;
}
return _.str.sprintf(pattern,
Math.floor(value),
Math.round((value % 1) * 60));
case 'many2one':
......
......@@ -71,6 +71,15 @@ $(document).ready(function () {
strictEqual(
openerp.web.format_value(0.0085, {type:'float', widget:'float_time'}),
'00:01');
strictEqual(
openerp.web.format_value(-1.0, {type:'float', widget:'float_time'}),
'-01:00');
strictEqual(
openerp.web.format_value(-0.9853, {type:'float', widget:'float_time'}),
'-00:59');
strictEqual(
openerp.web.format_value(-0.0085, {type:'float', widget:'float_time'}),
'-00:01');
});
test("format_float", function () {
var fl = 12.1234;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment