Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5670 มุมมอง

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])


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ม.ค. 20
15265
16
ส.ค. 19
10222
1
ม.ค. 19
5481
5
มิ.ย. 18
10881
0
ก.ย. 17
2522