Skip to Content
Menu
This question has been flagged
3 Replies
27973 Rodiniai

I want to know how to do difficult domains with operators, because if I have something easy as: 

(A & B) --> ['&', ('id', 'in', active_ids), ('partner_id', 'in', partner)]

I know to do it

But if I have

(A & B) | C 
or 
( (A & B) | C) |  (D & E) 
I don't know how to do it, because I don't know where I have to put the operators 
Portretas
Atmesti
Best Answer

Hello Celia,

Odoo use polish notation to manage all filters and its operator between two filters. For that you need to have a look inside polish notation if you dont know anything about it. http://en.wikipedia.org/wiki/Polish_notation

From your question : ( (A & B) | C ) | (D & E) will be formed as like below to manage domain inside Odoo.


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

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

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


I hope you will get exact idea that how domain is working in Odoo.




Portretas
Atmesti
Best Answer

I guess the #1 results in:

(((A & B) | C) & D) | E

doesn't it?

Portretas
Atmesti
Best Answer

My method for simplification:

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

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

(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)"

(3) 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 )

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) ] 

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
4
birž. 21
40561
1
gruod. 20
3310
1
bal. 18
8598
3
rugs. 15
10270
2
rugp. 15
6227