Merge lp:~openerp-dev/openerp-web/7.0-opw-581438-port-pan into lp:openerp-web/7.0

Proposed by Anand
Status: Merged
Merged at revision: 3717
Proposed branch: lp:~openerp-dev/openerp-web/7.0-opw-581438-port-pan
Merge into: lp:openerp-web/7.0
Diff against target: 37 lines (+13/-3)
2 files modified
addons/web/static/src/js/formats.js (+7/-3)
addons/web/static/test/formats.js (+6/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-opw-581438-port-pan
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Approve
Review via email: mp+144217@code.launchpad.net

Description of the change

Hello,

Float_time widget show wrong format of time.

Demo: Human Resources > Time Tracking > Time sheets
1) Create new record.
3) Enter 5.9999 quantity in Time-sheet Lines record and save.

Observed: "Difference" field value "05:60".
Expected: "Difference" field value "06:00".

And i used Math.round,
because Math.floor is not solving the problem.
 if we uses Math.floor(4.9999) output is ==> 04:59 and
 if we uses Math.round(4.9999) output is ==> 05:00

Attached video for that:-https://docs.google.com/open?id=0B0jT5NnR2uk-UzBNTGQ1UFRHcjg

Thanks.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Please add tests for behavior on boundaries of float_time. There are already some tests for this, can add new ones.

review: Needs Fixing
3710. By Anand

[IMP] Added some test cases for the float_time

Revision history for this message
Anand (anand-m-patel) wrote :

> Please add tests for behavior on boundaries of float_time. There are already
> some tests for this, can add new ones.
Hello,

I have added some test cases for the float_time.

Thanks,
PAN

Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/formats.js'
--- addons/web/static/src/js/formats.js 2012-11-29 00:22:00 +0000
+++ addons/web/static/src/js/formats.js 2013-01-23 09:35:24 +0000
@@ -166,9 +166,13 @@
166 value = Math.abs(value);166 value = Math.abs(value);
167 pattern = '-' + pattern;167 pattern = '-' + pattern;
168 }168 }
169 return _.str.sprintf(pattern,169 var hour = Math.floor(value);
170 Math.floor(value),170 var min = Math.round((value % 1) * 60);
171 Math.round((value % 1) * 60));171 if (min == 60){
172 min = 0;
173 hour = hour + 1;
174 }
175 return _.str.sprintf(pattern, hour, min);
172 case 'many2one':176 case 'many2one':
173 // name_get value format177 // name_get value format
174 return value[1] ? value[1].split("\n")[0] : value[1];178 return value[1] ? value[1].split("\n")[0] : value[1];
175179
=== modified file 'addons/web/static/test/formats.js'
--- addons/web/static/test/formats.js 2012-10-26 09:21:44 +0000
+++ addons/web/static/test/formats.js 2013-01-23 09:35:24 +0000
@@ -68,6 +68,12 @@
68 strictEqual(68 strictEqual(
69 instance.web.format_value(-0.0085, {type:'float', widget:'float_time'}),69 instance.web.format_value(-0.0085, {type:'float', widget:'float_time'}),
70 '-00:01');70 '-00:01');
71 strictEqual(
72 instance.web.format_value(4.9999, {type:'float', widget:'float_time'}),
73 '05:00');
74 strictEqual(
75 instance.web.format_value(-6.9999, {type:'float', widget:'float_time'}),
76 '-07:00');
71 });77 });
72 test("format_float", function (instance) {78 test("format_float", function (instance) {
73 var fl = 12.1234;79 var fl = 12.1234;