Could someone translate the following polish notation to its SQL counterpart:
[\'|\', \'&\', (\'is_company\',\'=\', True),(\'parent_id\', \'=\', False)
I totally agree with you, each time I have to do a complex domain using this kind of Polish notation, I have to rack my brains to manage it.
I think the domain you're looking for is:
['&', '|', '&', ('is_company', '=', True), ('parent_id', '=', False), ('company_name', '!=', False), '&', ('company_name', '!=', ''), ('customer_type_id', '!=', False)]
I made up a method to get these complex domains, and it's working:
First I write a letter instead of each condition:
A => is_company = True => ('is_company', '=', True)
B => parent_id = False => ('parent_id', '=', False)
C => company_name <> False => ('company_name', '!=', False)
D => company_name <> '' => ('company_name', '!=', '')
E => customer_type_id <> False => ('customer_type_id', '!=', False)
Then build the expression you need using only the letters and the standard operators, forget about the Polish notation and the conditions:
Step 0. => ((A and B) or C) and D and E
Afterwards, group the operations you should execute the first (don't mind about the missing operators by the moment):
Step 1. => ((A and B) or C) and D and E
Step 2. => (AB or C) and D and E
Step 3. => ABC and D and E
Step 4. => ABC and DE
Now we have only an operator, let's start decomposing it again (and moving the operator to the left of each couple of conditions), following the reverse order in which you grouped the operations (for example, from step 3 to 4 you grouped DE, so now, from step 4 to 3, decompose DE and move its operator to its left):
Step 4. => and ABC DE
Step 3. => and ABC and D E
Step 2. => and or AB C and D E
Step 1. => and or and A B C and D E
Now change the operators and add the commas, the quotes and the brackets:
['&', '|', '&', A, B, C, '&', D, E]
Finally, replace the letters with the conditions, and there you have your domain. It would be better to explain it face to face but may be you were able to understand everything.
Note: I don't remove the
&
operators (despite if you don't write them, Odoo should take them by default) because my experience is that with largest domains, if I didn't write the&
, the domain didn't work. I guess this happened when there was a lot of nested conditions, but my advice is to write always them.