Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
In what scenarios would we need to use '=ilike' in domain operation.
When we create a domain, we have multiple operators available in OpenERP 7 at server/openerp/osv/expression.py
TERM_OPERATORS = ('=', '!=', '<=', '<', '>', '>=', '=?', '=like', '=ilike', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of')
Can anyone provide me a scenario where we need to use these operators in domain:
As prakash says: The i is for case insensitive. While the "= prefix" searches for exact matching. Without the "= prefix", the orm will add % wildcards arround your search term.
[('name', 'like', 'dog')]
This will find recods with name 'dog', 'dogs', 'bulldog', ... but not 'Dog'.
[('name', '=like', 'dog')]
This will find records with name 'dog' (it's almost exactly like the '=' operator).
[('name', 'ilike', 'dog')]
This is the most universal search. It will find records with name 'dog', 'DOGS', 'Bulldog', etc..
['name', '=ilike', 'dog')]
This will find records with name 'dog', 'DOG', 'Dog', 'DOg', DoG', 'dOG', 'doG' and 'dOg'.
They use '=ilike' in your crm/wizard example to match the email case insensitively, so that any capital letter is ignored in the search, since some mail clients allow capitol letters in email addresses, while others doesn't, I think.
Honestly, I have never seen or used the '=?' operator...
I think 'child_of' is somethink like an iterative search for child-relations:
[('parent_id', 'child_of', root_id)]
This will list all children and their children ... and so on for the root_id.
ILIKE keyword in PostgreSQL provides case insensitive search.
The difference between like/ilike and =like/=ilike is that with like/ilike, Odoo automatically appends and prepends a '%' to the search string before passing it to the database. So [('name', 'like', 'dog')] is equivalent to [('name', '=like', '%dog%')]. So you could use =like if you need to find the search string at the only beginning of the column, for instance [('name', '=like', 'dog%')]
'=?' operator makes the term TRUE if right statement is None or False otherwise behaves like '='
if right is False or right is None:
# '=?' is a short-circuit that makes the term TRUE if right is None or False
query = 'TRUE'
params = 
# '=?' behaves like '=' in other cases
query, params = self.__leaf_to_sql( create_substitution_leaf(eleaf, (left, '=', right), model))
user_ids = users_obj.search(cr, uid, [('name', 'like', 'test'), ('parent_id', '=?', False)])
self.assertEqual(set(user_ids), set([a, b1, b2]), '(x =? False) failed')
As it is shown in example, parent_id cannot be False if value doesn't exist: '=?' returns True or parent_id value
About This Community
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 7/23/14, 1:55 AM|
|Seen: 25803 times|
|Last updated: 9/26/18, 8:22 AM|