Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
5529 Näkymät

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
Hylkää
Tekijä

Anyone?

Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
tammik. 20
15075
16
elok. 19
10069
1
tammik. 19
5322
5
kesäk. 18
10721
0
syysk. 17
2416