Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
11443 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 22
1586
1
jul 16
6420
1
oct 15
6340
2
may 25
10030
0
feb 23
3879