Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3394 Переглядів
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.

Related Posts Відповіді Переглядів Дія
2
лют. 22
7866
2
серп. 23
2393
0
жовт. 20
2852
4
жовт. 19
3627
2
лют. 24
81