Skip to Content
Menu
This question has been flagged
1 Reply
4216 Views

I'm new to Odoo and I am still creating and customizing my database. So please bear with me :)


we are using 2 currencies in our company (USD) & (EGP) I want to use the current exchange rate for the USD to calculate some revenue in one of the functions inside the Employees Module, to show some revenue related to some of the employees.


I activated the automatic currency rate feature and it's working fine, I just want to know how can I convert a given USD amount in a text field to display in another (read only) as in the EGP. How can I call for the exchange rate to use it in the equation?


I know some Python and I use it to do small calculations in these fields, but I have no idea how to use the current currency rate in the function. Any help? 

Avatar
Discard

Could you share a screenshot that indicates where you want to display the amounts in both currencies?

Author

@Yanelis I can't seem to find a way to share with you the screenshot here on the forums! Pardon my ignorance...

Don't worry, I can help. Follow this steps
- Take a screenshot
- Edit the picture and copy with (ctrl+c)
- Edit your question in the forum and copy the picture (ctrl+v)
- Save

Author

It said I need 20 Karma to be able to post a photo or link

Author

I will try to explain further. It's inside the employee module in the employee data, below there is a multi-tab window. I added a new tab that calculate some Expenses and Revenue related to that employee. The Expenses are all in EGP but the revenue are all in USD. So in order to calculate the final Net Revenue, I have to convert the USD to EGP with the updated rate. In the currency settings I already set the USD rate to update automatically on a weekly basis & this part working fine. My question is there a way to call for that rate to do my calculation automatically.

Best Answer

Hi 

To convert an amount from one currency to another in Odoo, you can utilize the default function `_convert` available in the `res.currency` model. This function provides a convenient way to perform currency conversion calculations.

Code sample:self.company_id.currency_id._convert(imbalance_amount, self.currency_id, self.company_id, fields.Date.context_today(self))
Definition:from_currency._convert(from_amount, to_currency, company, date)

Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
3
Mar 15
6512
1
Mar 15
9104
3
Apr 24
1812
3
Jun 24
5330
0
Oct 23
1420