コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4159 ビュー

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>
アバター
破棄
最善の回答

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

アバター
破棄
最善の回答

Hello GRF,

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

アバター
破棄
関連投稿 返信 ビュー 活動
1
4月 25
1304
2
3月 25
1495
4
11月 24
7166
1
3月 24
2100
3
9月 23
24942