Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4 Antwoorden
11470 Weergaven

Hello everybody,

I am on Odoo 10, and I'd like to use multi condition on domain  in xml.

This is the domain that I want to write:

(A and B) Or ( C and D).

How can I do it ?

Thanks.

Best regards

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Beste antwoord

Hi , 

Try This 

AND

<field ... domain="[('field_name', '=', id), ('field_name', '=', id) ]" />

OR:

<field ... domain="['|',('field_name', '=', id), ('field_name', '=', id) ]" />


look this 

https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-set-this-specific-domain-in-xml-83173


Avatar
Annuleer
Auteur

I want to write like this:

['|',(('field_name','=',value),('field_name1','!=',False)),(('field_name1','=',value),('field_name','!=',False))]

Can you provide us with the code so that I can help you?

Beste antwoord

Hi,

If you do not use "|"(pipe sign) then it will apply and condition.

if you use "|" (pipe sign) then it will apply or condition.

Please check my code:

OR condition domain="['|', ('field1', 'operator', value), ('field2', 'operator', value)]"

AND condition domain="[('field1', 'operator', value), ('field2', 'operator', value)]"
Hope above will help you.

Avatar
Annuleer
Beste antwoord

Hi,

You can write like this,

[ OR,  AND,  A,  B,   AND,  C,  D ]

Avatar
Annuleer