Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
11574 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
sty 22
1684
1
lip 16
6474
1
paź 15
6428
2
maj 25
10093
0
lut 23
3999