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
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
Display photos on qweb
تم الحل
|
|
3
أبريل 19
|
6780 | |
|
1
سبتمبر 18
|
7429 | ||
Odoo11 Custom Report
تم الحل
|
|
1
سبتمبر 18
|
7379 | |
|
1
فبراير 18
|
9094 | ||
|
1
أبريل 25
|
617 |