Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
19985 Vizualizări

Hii

I have two fields money and currency on a form. A user enters some amount and selects currency e.g. 500.00 - USD other than company currency.

I have added a third field i.e. money_local. I want to covert money field value to local currency and assign to money_local.

Should I make fields as Monetary or Float?

What is the currency conversion formula in Odoo python?

Imagine profil
Abandonează
Cel mai bun răspuns

There is a built-in method on currency to convert one currency to another like

>>> USD = self.env['res.currency'].search([('name', '=', 'USD')])
>>> EUR = self.env['res.currency'].search([('name', '=', 'EUR')])
>>> USD.compute(500, EUR)

448.53000000000003 

Create one computed field (monetary) and call compute method of currency to get the conversation rate.

Imagine profil
Abandonează

Hello, I'm needing pretty much the same but I require the compute to calculate with the exchange rate of a certain date, the confirmation_date for example. Do you have any tip of advice for OdooV11?

In newer version API has been chagne so you can user _convert instead of compute

https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/models/res_currency.py#L180 there you can pass date at which you want to convert currency

However, in the older version, you can pass date in context while converting the currency

https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/models/res_currency.py#L211

Cel mai bun răspuns

Dear 

We developed a dual Currency module , where we all transactions can be automatically saved in 2 main currencies ( for ex. SAR and USD)

bassem.riachi@analyb.com

www.analyb.com

Imagine profil
Abandonează
Autor

Thanks Bassem,

I need only on a form and for one field. At transaction level, odoo mostly keeps the value in both currencies.

Related Posts Răspunsuri Vizualizări Activitate
1
mar. 21
5634
1
iun. 18
4384
2
ian. 19
5694
3
ian. 16
10949
1
mar. 15
4135