Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
18706 มุมมอง

I want to 'AND', 'OR' condition in single search. 

docids = self.env['sale.product.list'].search([ (('branch_id', '=', a_market_id) '&' ('deli_user_id', '=', a_deli_user_id) '&' ('user_id', '=', a_user_id)) '|' (('branch_id', '=', a_market_id) '&' ('deli_user_id', '=', a_deli_user_id) ) ])
อวตาร
ละทิ้ง

By default 'search' function takes 'AND' condition between 2 args. You can add 'OR' / 'AND' via '|' / '&' signs.

คำตอบที่ดีที่สุด

Odoo domain is a typical Reverse Polish Notation representative, where operators follow their operands. Look at this wikipedia article for the detailed explanation.

So, '&' and '|' should be before the conditions. '&' might be not set explicitly.

  • ["&", A, B] > both A and B should be satisfied. The same as [A, B]

  • ["|", A, B] > either A or B should be True

  • ["&", A, "|", B, C] > A should be True AND (either B or C should be True)

  • ["|", A, "&", B, C] > Either A should be True OR  (both B & C should be True)

Have a look also at the similar Odoo question - https://www.odoo.com/es_ES/forum/ayuda-1/question/domain-notation-using-multiple-and-nested-and-2170 

อวตาร
ละทิ้ง

How about this one sir? "['|', '|', '&', A, B, C, D, E]"
I can't understand this domain.

คำตอบที่ดีที่สุด

in faOtools' answer, I don't understand why he says its "Reverse Polish Notation, where the operators follow their operands", but then he goes on to show operands following the operators.  Am I misunderstanding?



I believe it's actually just "Polish Notation" and not "Reverse Polish Notation" -- can anyone confirm? This point has been confusing me :)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

One fairly easy way to get familiar with the notation is to create user-defined filters through the standard Odoo front-end, and you can see what Odoo generates for various combinations of operators and conditions.  

https://odootricks.tips/domain-in-odoo/ 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Search a message แก้ไขแล้ว
1
ก.พ. 25
557
0
ก.ย. 23
1601
2
มิ.ย. 23
3275
1
ส.ค. 22
11869
7
ต.ค. 20
9625