Using database to compare and retrieve currency conversion rate
I am trying to loop through a database in order to do a comparison between the currency used by a supplier and the currency that Odoo has as the default currency. Lets say that the currency that is used by the supplier is the Euro. My default currency is the US Dollar. What I would like to do then, is take the currency used by the supplier, do a comparison by currency_id in the res_currency_rate table in the Odoo database. If both of them match, then I retrieve the exchange rate so that when I enter a price for a product from that particular supplier, the number is taken, multiplied by the conversion rate (USD to EUR) and then the converted price appears instantly on the screen. I want to avoid hard coding as much as possible, so that I can use this method with different suppliers who use different currencies.
I have searched and tried myself to figure out how to do this, but it does not work out.
To be more specific, here is where I am having trouble:
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