Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7882 มุมมอง

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.

Ex:

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

Thanks in advance.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The odoo will convert float to float_time like below


# Import math Library

import math

input_value = 0.16666667

hours, minutes = divmod(input_value * 60, 60)

result = '%02d:%02d' % (hours, minutes)

print(result)


Output: 00:10

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The number 0.16666667 was obtained from the division between 10 divided by 60 (rounded version of the real amount which is 0.16666666666 ​...). The formula happened because of the relation between minute and second where 1 minute = 60 seconds. Therefore, in this ​ widget="float_time" case, Odoo converted the 10 seconds into the amount determined in minute.​​​​​​​

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มี.ค. 17
3976
1
พ.ค. 24
3479
3
ต.ค. 24
34219
1
เม.ย. 20
16011
2
พ.ค. 21
5261