Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
10714 Widoki

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?

Awatar
Odrzuć
Autor Najlepsza odpowiedź

         <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 

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

sorry niyas you dont get what i mean..

Then could you please explain

Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
3
kwi 19
7061
1
wrz 18
7817
1
wrz 18
7598
1
lut 18
9409
1
kwi 25
1023