This question has been flagged
5 Replies
9768 Views

Hello everyone,

In order to get get the right precision decimal in invoice report I had used this one:

<span t-esc="'%.3f'%(o.amount_total)"/>

but my problem now is how to get the currency I have used this one but I could not print the invoice report I'm getting an error

<span t-esc="'%.3f'%(o.amount_total)" t-esc-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>

Any help please

Avatar
Discard
Author Best Answer

I had founded the solution:

<span t-esc="'%.3f'%o.amount_total"/>&amp;nbsp;<span t-esc="o.currency_id.symbol"/>

Thanks for all

Avatar
Discard
Best Answer

Try the following:

<span t-esc="round(o.amount_total, 3)" t-esc-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
The '3' option specifies the amount of decimals you want to display. If you want to display only the integer number, then use:
<span t-esc="int(round(o.amount_total, 0))" t-esc-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
Avatar
Discard
Author

Hello,

If I use the first option I don't get 3 number as decimal precision I only get 2 and I need 3 number.

Any help please

@Jihen BEN ALI, perhaps you should check the following items:

- check that the number you want to display has 3 decimals? A trailing zero is automatically cut with the python round function.

- If you want to force displaying zero's, perhaps you should try to work with the decimal library from python. https://docs.python.org/2/library/decimal.html

From there you could force the zeroes to display.

A third option would be to use this formatting string in the t-esc attribute:

t-esc="'{:.3f}'.format(o.amount_total)"