跳至內容
選單
此問題已被標幟
1 回覆
3419 瀏覽次數
def currency_convert(amount, currency):
SAR = docs.env['res.currency'].sudo().search([('name', '=', 'SAR')])
convert_currency = currency.compute(amount, SAR)
return convert_currency

This function convert into sar with latest exchange rate but i want it to convert with according to date same as invoice date and exchange rate date help please i tried but not getting it



頭像
捨棄
最佳答案

Hi Muhammad Kamil,
Compute function has already that functionality. You need to pass the date with context and called the compute method from the currency model.Please try with this code.

    convert_currency = currency.with_context(date= your invoice date).compute(amount, SAR)


This will find the currency rate <= to your invoice date.
Hope it will help you
Please Vote for the Answer if works.

頭像
捨棄

Hi Malay,

I'm trying it from € to usd in qweb

<t t-set="convert_currency" t-value="o.currency_id.with_context(date = o.date).compute(o.amount_total, USD)" />
<t t-esc="convert_currency" />
but it doesn't work, it show the same amount, what I'm doing wrong?
br

Hi,
Please check your record currency "o.currency_id".
Please check the date "o.date" and the currency rate for the USD.

Please check the condition of currency rate date <= to your invoice date.

Hope it will help you.

相關帖文 回覆 瀏覽次數 活動
2
2月 22
7890
2
8月 23
2422
0
10月 20
2882
4
10月 19
3662
2
2月 24
81