Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
11542 Zobrazení

Hi Odoo developers.

I'm reading the reference provided to workflows from the odoo.com web page (https://www.odoo.com/documentation/8.0/reference/workflows.html), but I don't understand the following.

In the Transitions-Conditions section, it is said:

In the condition evaluation environment, several symbols are conveniently defined (in addition to the Odoo safe_eval environment):

- all the model column names, and
- all the browse record’s attributes.

But what is the safe_eval environment?. Any example is welcomed.

Thanks in advance.

Avatar
Zrušit
Nejlepší odpověď

The safe_eval environment in Odoo refers to a set of Python expressions that are considered safe to evaluate, and which are used to evaluate conditions in workflows. The safe_eval environment includes a limited set of Python built-in functions and methods, as well as a number of additional symbols that are specific to Odoo, such as column names and browse record attributes. This allows you to use Python expressions to evaluate conditions in workflows, without allowing arbitrary code execution.

For example, you could use an expression like state in ('draft','sent') in a workflow transition condition to evaluate whether the current state of a record is either draft or sent. This expression would be evaluated in the safe_eval environment, and would return True if the current state matches either of those values, and False otherwise.

Avatar
Zrušit
Nejlepší odpověď

It is a restricted environment that will prevent you from accidentally shooting yourself in the foot. For example, let's say you have a custom Python code that is executed when an event happens - in that code you cannot import modules, or interact with the file-system, because these would be potentially unsafe actions.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
led 22
1660
1
čvc 16
6457
1
říj 15
6412
2
kvě 25
10077
0
úno 23
3958