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

Dear all,

I am using Odoo 12 and have a report that shows integer values without thousands separator. For instance: 1000.

What I need to do is to show this value with the thousands separator, like: 1.000 (using "." - dot)

I was able to do it for "," as the separator, but not the "." (dot), and I really need the "." - dot as the separator.

For the "," I have used (achieved 1,000):

<t t-esc="'{0:,.0f}'.format(int(line['my_value']))"

Can anyone help me achieve the same result with the "." (dot) thousands separator?

Thank you all in advance

Best regards

Paulo


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

Dear all,

For those having the same problem, I have found a solution for Odoo 12 and qweb reports.

I just had to use ".replace(',', '.')"" on the code above, replacing the "," for the ".".

With "replace", we can use anything we need as a thousand separator, like  a space for instance, " " (1 000).

So the final code I have used is:

<t t-esc="'{0:,.0f}'.format(int(line['my_value'])).replace(',', '.')" />

Thank you once again

Best regards

Paulo

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

Or you find the settings for 1000 separator in the setting for language.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 21
2779
1
thg 4 25
3435
0
thg 3 24
1285
0
thg 1 24
1531
0
thg 1 24
1233