تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5640 أدوات العرض

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
يناير 20
15215
16
أغسطس 19
10178
1
يناير 19
5422
5
يونيو 18
10836
0
سبتمبر 17
2476