Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
11503 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Jan 22
1635
1
Jul 16
6447
1
Okt 15
6390
2
Mei 25
10062
0
Feb 23
3940