Skip to Content
Menú
This question has been flagged
2 Respostes
4160 Vistes

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
Descartar
Best Answer

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
Descartar
Best Answer

Hello GRF,

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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
d’abr. 25
1314
2
de març 25
1502
4
de nov. 24
7182
1
de març 24
2111
3
de set. 23
24961