Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Decimal precision

By
Jihen BEN ALI
on 6/14/16, 5:40 AM 332 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

0
Jihen BEN ALI
On 6/15/16, 3:49 AM

I had founded the solution:

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

Thanks for all

0
Pieter Paulussen
On 6/14/16, 9:52 AM

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"}'/>

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
on 6/15/16, 3:02 AM

@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)"

Pieter Paulussen
on 6/15/16, 3:14 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/14/16, 5:40 AM
Seen: 332 times
Last updated: 6/15/16, 3:49 AM