跳至內容
選單
此問題已被標幟
2 回覆
5415 瀏覽次數

Hello,

I am trying to loop through a database and retrieve the currency conversion rate.  I have been trying to figure it out on my own and looking through documentation and sample code, but to no avail.  The primary problem is with the search function.  I can't figure out what I can do to make it work properly. 

Here is the code:

id = self.supplier_name.currency.id 
curr_rec = self.env['res.currency.rate'].search([id,'=', 'currency_id'])
for rec in curr_rec:
   if curr_rec == 'res.currency.rate.currency_id':
     self.price_EUR = self.price * self.supplier_name.currency.rate

頭像
捨棄
作者

Anyone?

最佳答案

Hey ! 

I think that the error is in how you put the condition in search.

instead of putting it like this :


curr_rec = self.env['res.currency.rate'].search([id,'=', 'currency_id'])

You need to do this : 

curr_rec = self.env['res.currency.rate'].search(['currency_id','=', id])


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
1月 20
14943
16
8月 19
9979
1
1月 19
5235
5
6月 18
10632
0
9月 17
2339