Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

XML for filters Odoo

By
Francine Maltais
on 4/5/15, 10:01 PM 1,204 views

Hello everyone

I need your help for my XML of my filters.

When I want to create a filter, I have these choices:

contains

doesn't contain

is equal to

is not equal to 

...........


If I want my filter contains certain words, what is the symbol that I have to use instead of '=' in domain :


<record id="filters_lapagept.creations_au_pt" model="ir.filters">

<field name="name">Créations Au fil du tempS</field>

<field name="model_id">stock.location</field>

<field name="user_id" eval="False"/>

<field name="domain">[('company','=','Créations Au')]</field>

</record>


I tried 'in' but it gives me an error message

what is my mistake? 

Thank you for your help.

3

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 4/5/15, 10:15 PM

like or ilike operator ...

developer book :


https://doc.odoo.com/v6.0/developer/2_5_Objects_Fields_Methods/methods.html/


Expressing a search domain (args)

Each tuple in the search domain needs to have 3 elements, in the form: ('field_name', 'operator', value), where:

field_name must be a valid name of field of the object model, possibly following many-to-one relationships using dot-notation, e.g 'street' or 'partner_id.country' are valid values.

operator must be a string with a valid comparison operator from this list: =, !=, >, >=, <, <=, like, ilike, in, not in, child_of, parent_left, parent_right The semantics of most of these operators are obvious. The child_of operator will look for records who are children or grand-children of a given record, according to the semantics of this model (i.e following the relationship field named by self._parent_name, by default parent_id.

value must be a valid value to compare with the values of field_name, depending on its type.

Domain criteria can be combined using 3 logical operators than can be added between tuples: '&' (logical AND, default), '|' (logical OR), '!' (logical NOT). These are prefix operators and the arity of the '&' and '|' operator is 2, while the arity of the '!' is just 1. Be very careful about this when you combine them the first time.

Here is an example of searching for Partners named ABC from Belgium and Germany whose language is not english

[('name','=','ABC'),'!',('language.code','=','en_US'),'|',('country_id.code','=','be'),('country_id.code','=','de'))

The '&' is omitted as it is the default, and of course we could have used '!=' for the language, but what this domain really represents is:

(name is 'ABC' AND (language is NOT english) AND (country is Belgium OR Germany))


other info :

 

i know operator ilike already with regard to sql. It will perform this way when placing in where class

'PSS01' ilike 'pss01' -> will return true

'PSS01' ilike '%ss01' -> will return true

'PSS01' ilike 'ss01' -> will return false

But in openerp 7, it performs this way

'PSS01' ilike 'pss01' -> returns true

'PSS01' ilike 'ss01' -> returns true **(it should return false


OpenERP version 7 automatically wraps the right handed value of ilike operator inside percents. So when you write the domain

[('name', 'ilike', 'ss01')]

OpenERP convert it to

name ilike '%ss01%'

To avoid having these wildcard characters added, you have to use the =ilike operator.

[('name', '=ilike', 'ss01')]

will be converted to

name ilike 'ss01'

0
Francine Maltais
On 4/6/15, 9:17 AM

Tank you!

It's really interesting

It'll help me a lot

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/5/15, 10:01 PM
Seen: 1204 times
Last updated: 4/6/15, 2:53 PM