In Odoo, I set decimal precision to be 4 for a field. Let's call it price
.
The field price
now has a value with 4 decimal places in the database.
It is displayed in a QWEB report, as expected, with 4 decimal places.
However, I need to display it only the first 2 decimal places with round down method.
Desired examples of price
before and after the rounding.
13.4567 ==> 13.45
5.0010 ==> 5.00
97.8391 ==> 97.83
How to achieve such requirement?
You could use:
<span t-esc="'%.2f'%(o.price)"/></span>
or:
<span t-esc="o.price" t-options='{"widget": "float", "precision": 2}'/>
For gane a better control of round precision(up o down) you could write a function to call from qweb that takes o.price
and retrieve a desired value.
I hope this can be helpful for you.