Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
217 Переглядів

Hello Odoo Community,

I’m currently working on an automation in Odoo Online where I need to convert the invoice subtotal (EUR) to another currency (GNF) using the exchange rate. I found the technical name for the rate field, but I’m encountering an issue when trying to use it in my automation.

Here’s what I’m trying to do:

  1. I want to use the invoice_currency_rate (or the corresponding field) to get the exchange rate for currency conversion.
  2. I’m trying to access the field in an automated action and perform the conversion on the invoice subtotal.

However, every time I try to use the field invoice_currency_rate, I get the following error:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/18.0/odoo/tools/safe_eval.py", line 397, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "", line 1, in <module>
NameError: name 'invoice_currency_rate' is not defined

What I’ve Tried:

  • I’ve confirmed that the technical name I’m using is correct.
  • I double-checked that the field should be available on the same model (account.move.line), but it still throws the error.
  • I’ve tried different ways to reference the invoice_currency_rate (e.g., record.invoice_currency_rate, record.currency_id.rate), but nothing seems to work.

My Understanding:

From my research, I believe the issue could be related to how the invoice_currency_rate is stored and accessed within Odoo. My guess is that it might not be directly available under the account.move.line model, but when I check, the field appears to be there.

Could anyone guide me on:

  1. The correct way to access the exchange rate in automations.
  2. Why I might be encountering this error and how to fix it.

I’d appreciate any help or suggestions! I've attached a screenshot showing the error if that helps.

Thanks in advance for your assistance!


Аватар
Відмінити
Автор Найкраща відповідь

I found the answer. My formula was wrong, but the way I called the field was right.
record.price_subtotal / record.move_id.invoice_currency_rate

Thank you

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лют. 25
773
1
трав. 24
1040
0
лист. 23
2996
1
трав. 25
230
0
трав. 25
20