Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
5645 Ansichten

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

Avatar
Verwerfen
Autor

Anyone?

Beste Antwort

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


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Jan. 20
15227
16
Aug. 19
10185
1
Jan. 19
5444
5
Juni 18
10843
0
Sept. 17
2482