hello guys can i add separator in my qweb template?
like example i have field price_unit = 1500.20
then i use this <span t-esc="'{:g}'.format (l.price_unit)"/>
it will be 1500.2 but can i make it 1.500,2?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hello guys can i add separator in my qweb template?
like example i have field price_unit = 1500.20
then i use this <span t-esc="'{:g}'.format (l.price_unit)"/>
it will be 1500.2 but can i make it 1.500,2?
<xpath expr="//span[@t-field='l.price_unit']" position="replace">
<t t-set="value_split" t-value="'{:g}'.format(l.price_unit)"/>
<t t-set="decimal_split" t-value="str(value_split).split('.')"/>
<t t-set="add_separators" t-value="'{:,}'.format(int(decimal_split[0]))"/>
<t t-set="result" t-value="add_separators.replace(',', '.')"/>
<t t-if="len(decimal_split) > 1">
<t t-set="final_result" t-value="','.join([result, decimal_split[1]])"/>
</t>
<t t-if="len(decimal_split) == 1">
<t t-set="final_result" t-value="result"/>
</t>
<span t-esc="final_result"/>
</xpath>
found the answer
Hi,
You can do it from Settings -> Translations -> Language, open the user language, set the Thousands Separator as . , might be right now it will be empty .
And if you need to change the Decimal separator to , instead of . , you can change it from the same screen, you can see a field with label Decimal Separator
See this image: https://imgur.com/aHZ0bPa
Thanks
sorry niyas you dont get what i mean..
Then could you please explain
i have field price_unit and i want to show it but remove the unused decimal like if you have value for 20000,320 it will be 20000,32 by using '{:g}'.format(l.price_unit) but i also want to add separators so it will show in my report like this 20.000,32
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
Display photos on qweb
Solved
|
|
3
Apr 19
|
6100 | |
|
1
Sep 18
|
6541 | ||
Odoo11 Custom Report
Solved
|
|
1
Sep 18
|
6734 | |
|
1
Feb 18
|
8213 | ||
|
4
Nov 24
|
5239 |