OdooTech notes

Odoo Python use of like in self.env.search Domains

python programming programmazione da zero python

Direttamente da questo articolo Odoo Forum, riporto questo utile vademecum per l’utilizzo dell’operatore like in sel.env.search per operazioni di selezione sui domini:

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.

Examples:

[(‘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.

 

Comment here