Odoo Help


Conversion from float_time to float [Closed]

Sudhir Arya (ERP Harbor Consulting Services)
on 11/20/13, 7:29 AM 2,436 views

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
on 11/21/2013 02:53:40

As we all know that we can use float field for time with the help of widget="float_time".

Now, my question is that how this float_time value is calculated/converted into float value.


I am giving value 00:10 in my form and when I look into the db it shows 0.16666667.

Thanks in advance.

Prajul P T
On 11/20/13, 8:28 AM

This is the code in js for displaying value in float_time format:

case 'float_time':
    var pattern = '%02d:%02d';
    if (value < 0) {
        value = Math.abs(value);
        pattern = '-' + pattern;
    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);

So in your case, in db it is stored as 0.16666667. So the min will be var min = Math.round((0.16666667 % 1) * 60); which will be 10 when rounded...

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/20/13, 7:29 AM
Seen: 2436 times
Last updated: 9/30/17, 6:20 AM