Skip to Content
Menú
This question has been flagged
1 Respondre
17264 Vistes

i want to set multiple (&) and  (|) in single search method.

i have these Many2many field-

self.env.[sale.order].search(

    (saleorders ID in m2m OR all ID) AND (customers ID in m2m OR all ID) AND (salespersons in m2m OR all ID)


Avatar
Descartar
Best Answer

Hello

I will link you to an existing answer which breaks down the process nicely:

https://www.odoo.com/en_US/forum/help-1/question/domain-notation-using-multiple-and-nested-and-2170


Essentially, you want to solve the order by abstracting the search logic and then re-adding your details afterwards.


I think (I have not tested) your search would break down to:

AND AND OR A B OR C D OR E F


Once I substitute your values back in, you would be left with:

'&', '&', '|', (saleorders ID in m2m), (all ID), '|', (customers ID in m2m), (all ID), '|', (salespersons in m2m), (all ID)


Again, I'm not certain that logic will work, but you should be able to come close with the process described in the link above.

Good luck!

Avatar
Descartar
Autor

Hello Travis,

actually, i have problem like this.

all r M2M and search in sale_order with IN condition.

search( [( A & B & C & D) or (A & B & C) or (A & B) or (A) or (B) or (C) or (D)])

how to set conditions like above . please give me any solution.

In that case, check the answer here about complex domain with many2many fields: https://www.odoo.com/forum/help-1/question/complex-many2many-domains-in-views-41777#answer_41784

However, for the search you commented, I think you should be able to simplify it a lot (assuming there are only 4 variables total).

It would be able to break down to: search([A OR B OR C OR D])

In Polish Notation: search(['|', '|', '|', (A), (B), (C), (D)])

Related Posts Respostes Vistes Activitat
0
de febr. 25
18
0
de maig 23
2666
2
de set. 21
22047
2
de des. 20
5375
6
de set. 20
19931