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
1=== modified file 'addons/web/static/src/js/formats.js'
2--- addons/web/static/src/js/formats.js 2012-11-29 00:22:00 +0000
3+++ addons/web/static/src/js/formats.js 2013-01-23 09:35:24 +0000
4@@ -166,9 +166,13 @@
5 value = Math.abs(value);
6 pattern = '-' + pattern;
7 }
8- return _.str.sprintf(pattern,
9- Math.floor(value),
10- Math.round((value % 1) * 60));
11+ var hour = Math.floor(value);
12+ var min = Math.round((value % 1) * 60);
13+ if (min == 60){
14+ min = 0;
15+ hour = hour + 1;
16+ }
17+ return _.str.sprintf(pattern, hour, min);
18 case 'many2one':
19 // name_get value format
20 return value[1] ? value[1].split("\n")[0] : value[1];
21
22=== modified file 'addons/web/static/test/formats.js'
23--- addons/web/static/test/formats.js 2012-10-26 09:21:44 +0000
24+++ addons/web/static/test/formats.js 2013-01-23 09:35:24 +0000
25@@ -68,6 +68,12 @@
26 strictEqual(
27 instance.web.format_value(-0.0085, {type:'float', widget:'float_time'}),
28 '-00:01');
29+ strictEqual(
30+ instance.web.format_value(4.9999, {type:'float', widget:'float_time'}),
31+ '05:00');
32+ strictEqual(
33+ instance.web.format_value(-6.9999, {type:'float', widget:'float_time'}),
34+ '-07:00');
35 });
36 test("format_float", function (instance) {
37 var fl = 12.1234;