Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
17306 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
0
Feb 25
18
0
Mei 23
2702
2
Sep 21
22096
2
Des 20
5416
6
Sep 20
19965