How to turn these expressions into Reverse Polish Notation?

578 views Asked by At

I am working with Odoo 8 and I want to set a couple of domains. I thought I understood reverse Polish notation but domains are not working so I guess I am wrong.

The domains I want to achieve using reverse Polish notation are:

  • A and B and C and (D or (E and F)): I tried to implement it with the expression A B C or D E F, but it did not work.

  • A and B and (C or D or (E and F)): I tried to implement it with the expression A B or or C D E F, but it did work neither.

Note: I am not writing ANDs in domains (if you do not specify anything in Odoo, it is supposed to use &).

My domains are wrong because I always get no record.

Can anyone help me, please?

1

There are 1 answers

0
forvas On BEST ANSWER

I have the answer. Despite if you do not specify anything, Odoo takes an AND by default, you must write ANDs when there are expressions which must be executed before other and Odoo does not know which are because you have a complex and long expression.

In my cases, E and F must be executed before any other expression, so we cannot leave them without AND, so:

  • A and B and C and (D or (E and F)): The solution is A B C or D and E F.
  • A and B and (C or D or (E and F)): The solution is A B or or C D and E F.

In an XML domain in Odoo, these domains will be:

  • [A, B, C, '|', D, '&', E, F].
  • [A, B, '|', '|', C, D, '&', E, F].

Where each letter will be an expression like ('field', 'operator', 'value').

Note: ampersands must be escaped.

EDIT

I have answered a question here:

I don´t understand Normal Polish Notation (NPN or PN). How to build a complex domain in Odoo?

In which I explain with details a great method to resolve complex domains. I hope it helps to someone.