Here are steps on how to compose Odoo domain with complex/ nested conditions:
Start with the outermost operator and move it to the start of the expression.
"(A operator B)" becomes "operator (A B)"
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)"
Remove all brackets.
"A operator (B operator C)" becomes "operator A operator B C"
So for my example:
( A or B ) AND ( C or D or E )
AND ( A or B ) ( C or D or E )
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 ) )
AND or A B or C or D E
In Odoo domain syntax this would be:
[ '&', '|', (A), (B), '|', (C), '|', (D), (E) ]
Visit http://udemy.com/user/akhmaddaniel for more tricks.