Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4174 Näkymät

In qweb report I have this code. but how can I make string dynamic according to currency? 

<span t-if="o.currency_id.name == 'USD'">
<th style="width: 12%;" class="text-right"><t>Unit Price ( USD )</t><br/>Unit Price (USD)</th>
<th style="width: 12%;" class="text-right"><t>Amount ( USD ) </t><br/>Amount (USD) <span t-esc="get_currency_codes()"/></th>
</span>
<span t-if="o.currency_id.name == 'EUR'">
<th style="width: 12%;" class="text-right"><t>Unit Price ( EUR )</t><br/>Unit Price (EUR)</th>
<th style="width: 12%;" class="text-right"><t>Amount ( EUR ) </t><br/>Amount (EUR) <span t-esc="get_currency_codes()"/></th>
</span>
Avatar
Hylkää
Paras vastaus

Hi Grf,

Why don't you simply print the name of the currency in order to get it in the column? You don't need all those t-if statements if you use the same code and you can access the value right away. I see that both strings are identical - except for the currency name - in every t-if statement so a cleaner solution would be:

<span>
<th style="width: 12%;" class="text-right"><t>Unit Price ( <span t-esc="o.currency_id.name" )</t><br/>Unit Price (<span t-esc="o.currency_id.name")</th>
<th style="width: 12%;" class="text-right"><t>Amount ( <span t-esc="o.currency_id.name" ) </t><br/>Amount (<span t-esc="o.currency_id.name") <span t-esc="get_currency_codes()"/></th>
</span>

I cannot see what you do with the function get_currency_codes though and we are missing context/more info but I think this is what you want. Please do add more details in your new questions.

Regards,
Yenthe

Avatar
Hylkää
Paras vastaus

Hello GRF,

By using currency_id we can get name,rounding factor,symbol.

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
huhtik. 25
1352
2
maalisk. 25
1543
4
marrask. 24
7227
1
maalisk. 24
2148
3
syysk. 23
24991