Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3381 Visualizzazioni
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



Avatar
Abbandona
Risposta migliore

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.

Avatar
Abbandona

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.

Post correlati Risposte Visualizzazioni Attività
2
feb 22
7848
2
ago 23
2389
0
ott 20
2835
4
ott 19
3581
2
feb 24
81