Odoo Domain notation using multiple and nested '|' and '&'

vITraining Admin

Here are steps on how to compose Odoo domain with complex/ nested conditions:

Step 1

Start with the outermost operator and move it to the start of the expression.

"(A operator B)"  becomes  "operator (A B)"

Step 2

Repeat step 1 for each sub expression with an operator to move.

"A operator (B operator C)"  becomes  "operator A (B operator C)"  then "operator A (operator B C)"

Step 3

Remove all brackets.

"A operator (B operator C)"  becomes  "operator A operator B C"

Example

So for my example:

( A or B ) AND ( C or D or E )

First simplification:

AND ( A or B ) ( C or D or E )

left side

AND ( or A B ) ( C or D or E )

right side outer

AND ( or A B ) ( or C ( D or E ) )

right side inner

AND ( or A B ) ( or C ( or D E ) )

remove brackets

AND or A B or C or D E

In Odoo domain syntax this would be:

[ '&', '|', (A), (B), '|', (C), '|', (D), (E) ]


This are topics we discuss in Odoo Technical Training by vitraining.com. For more information about schedules please click shop.vitraining.com/event.