Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
16993 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
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 Odpovědi Zobrazení Aktivita
0
úno 25
18
0
kvě 23
2353
2
zář 21
21545
2
pro 20
5081
6
zář 20
19695