Skip to Content
Menu
This question has been flagged
3 Replies
9543 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Jan 22
826
1
Jul 16
5353
1
Oct 15
5402
3
Apr 23
8686
0
Feb 23
2169