Help

3

Understand Open Erp Domain Filter ?

Avatar
Mohd Ahmad

HI I would like to ask you if you could please explain the anatomy of the Openerp domain filters. I have to use it my project. Please explain the anatomy and description of the following domain filter .

['|',('order_id.user_id','=',user.id),('order_id.user_id','=',False)]

If you are having any resource concerning the same then please share it .

Thanks in advance ..

Avatar
Discard
3 Semua Jawaban
4
Avatar
AJ Schrafel Paper Corp
Best Answer

Domains are tuples, the structure is (field, operator, value).

Field is the data in the database, Operator is the comparison, = equal, != not equal, > greater than, < less than, etc. Value is the data you want to compare with the field, it can be another database field, a constant or a calculated value.

Typically when you send a domain into a function it is sent as an array so it must be contained with in brackets [ ] whether you have 1 or more tuples.

The default operator between tuples in the array is & (AND), to modify that you can use | to indicate OR

So in your example the domain is ['|',('order_id.user_id','=',user.id),('order_id.user_id','=',False)]

translated in to human: orders with the same user id OR a blank user id will be part of the domain.

Without seeing the rest of the code a better answer cannot be given on what exactly the domain will be because user.id is not known from that code alone.

Avatar
Discard
1
Avatar
Francesco OpenCode
Best Answer

This is the system used to create the structure for the domain:

https://en.wikipedia.org/wiki/Polish_notation

Study it (search Polish notation on a search engine) to understand this structure.

2 Komentar
Avatar
Discard
Avatar
Mohd Ahmad
-

Hi thanks for the answer. but my actual concern is the anatomy .I want to know the exact meaning of (order_id.user_id','=',user.id) , what is order_id , user_id, and user.id. are they referencing any table . if yes then how am i supposed to know which one .... basically i want to know decipher the notation from bottom up so that can use it as per my requirement.

Avatar
Akhmad Mizkat
-

Hi Ahmad, if you want to know the meaning of order_id.user_id, here is my thought : in your entity that contain domain above, you have an attribute named order_id which typed as many2one with your another entity. So the "order_id.user_id" is refer to the user_id column in your another entity which referenced as many2one by the order_id attribute. As for the "user.id", I have no idea where is that come from, because your snippet code is too short. Hope this help.. :)

0
Avatar
Mohammed Mansour
Best Answer

You will find the answer here by @Ray Carnes

Really it's very good answer

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

and to read more about Openerp Polish notation open this link http://en.wikipedia.org/wiki/Polish_notation

Avatar
Discard