Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
18351 Vistas

I read following document about expressing a search domain (args) for xml-rpc:

https://doc.openerp.com/trunk/server/api_models/

Where it's explained how to write the following query:

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

To get:

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

The arity of the '&' and '|' operator is 2, so how can I wrote the following query:

(name is 'ABC' AND (language is NOT english) AND (country is Belgium OR Germany OR France OR Italy))
Avatar
Descartar
Mejor respuesta

Hi Yann,

Try with this. You can write following in XML-RPC

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

as

['|','|','|',('country_id.code','=','be'),('country_id.code','=','ge'),('country_id.code','=','fr'),('country_id.code','=','it'),('name','=','ABC'),('language.code','!=','en_US'),]

Country code maybe different you can replace country code with correct one in above sentense.

Thanks,
www.acespritech.com

Avatar
Descartar

Perfect explanation.

Mejor respuesta

You can query like this:

args = [('name','=','ABC'),'!',('lang','=','en_US'), '|', '|',('country_id.code','=','be'),('country_id.code','=','de'), ('country_id.code', '=', 'fr')]

The line above shows only 3 OR, but 4 would be similar.

This:

args = [('name','=','ABC'),'!',('lang','=','en_US'), '|', '|',('country_id.code','=','be'),('country_id.code','=','de'), '!',  ('country_id.code', '=', 'fr')]

would mean:

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

(even if that does not really make sense!)

Avatar
Descartar