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

Hello I am trying to print the account.move model, and all is ok, but I need that the numbers appear like money "1,465.00", i can't show thtat with the to=housand separator and the 2 decimals.

Can someone help me and say me how.

This is the form that i am using for call the element: <t t-esc="line.credit" />

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

I have solved that. If someone help this:

      <t t-esc="'{0:,.2f}'.format(int(line.credit))" />

อวตาร
ละทิ้ง

Could you please elaborate on what {0:,.2f}'.format(int(line.credit)) means?

Good answer, work like a charm

Hi Javier Batres

Thanks for your answer is really helpful. Is there a way to change the type of the format you choose (instead of "," I want to use space " ". Instead of "." I want to use ",")

I'm still waiting for your answer, thanks in advance

Hi Othman you can use .replace

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

คำตอบที่ดีที่สุด

you don't need to hard code your report with a specific format. so you can use the built in formats of odoo to support multi currency. as the following example

<t t-field="line.credit" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}' />

also you need to check & make sure about the following settings that match your need

Settings -> Translations -> Languages -> 'your language settings'

seperator format should be something like [3,0]

for more info go to http://openerp-server.readthedocs.org/en/latest/06_ir_qweb.html

อวตาร
ละทิ้ง

does this work only for Monetary type field?

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 24
1995
How do i create report in Qweb? แก้ไขแล้ว
5
ส.ค. 19
46567
4
มิ.ย. 18
20141
0
มิ.ย. 18
3351
What is QWeb (Odoo's reporting engine)? แก้ไขแล้ว
2
พ.ค. 16
17057