Skip to Content
Menu
This question has been flagged
2 Replies
3589 Views

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

Hello GRF,

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

Avatar
Discard
Related Posts Replies Views Activity
4
Nov 24
5238
1
Mar 24
399
3
Sep 23
22661
0
Feb 24
1718
1
Oct 22
2795