Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
3734 Lượt xem

Hi Community,

I have a field in python having the value of 16788.145 when i put this on report template it displays as 16788.15.How can i solve this issue.I need 16788.14 in the report

Thanks in advance

Ảnh đại diện
Huỷ bỏ

How to stop auto rounding of float fields in odoo: https://goo.gl/groZgT

Câu trả lời hay nhất

Hi,

Try the following code


import math
custom_value = math.floor(16788.145 * 10 ** 2) / 10 ** 2

Regards


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

In the report template, you can give it like this t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}' along with t-esc or span.

Sample:

<t t-esc="l['quantity']" t-options='{"widget": "float", "decimal_precision": "Product Unit of Measure"}'/>

You can change the decimal_precision accordingly.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 18
2758
3
thg 2 25
19357
1
thg 12 22
4001
1
thg 10 22
2566
1
thg 11 18
3135