跳至内容
菜单
此问题已终结
2 回复
4157 查看

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
1302
2
3月 25
1487
4
11月 24
7161
1
3月 24
2095
3
9月 23
24928