콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3385 화면
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
7852
2
8월 23
2389
0
10월 20
2838
4
10월 19
3587
2
2월 24
81