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
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
RegistrierenVerknüpfte Beiträge | Antworten | Ansichten | Aktivität | |
---|---|---|---|---|
Display photos on qweb
Gelöst
|
|
3
Apr. 19
|
7067 | |
|
1
Sept. 18
|
7820 | ||
Odoo11 Custom Report
Gelöst
|
|
1
Sept. 18
|
7601 | |
|
1
Feb. 18
|
9414 | ||
|
1
Apr. 25
|
1027 |