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.

2

How to use logical OR operator with XML-RPC ?

By
Yann Papouin
on 7/24/13, 7:16 AM 4,538 views

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))
1

Acespritech

--Acespritech--
839
| 3 2 6
India
--Acespritech--

Having 8+ years of OpenERP Experience. We are Specialized in OpenERP/CRM Solutions, software development, Web development, E commerce solutions & other open source solutions.


Skype : acespritech

Email : info@acespritech.com

Acespritech
On 9/27/13, 5:27 AM

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

0
martin mueller
On 9/26/13, 9:53 PM

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!)

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: 7/24/13, 7:16 AM
Seen: 4538 times
Last updated: 3/16/15, 8:10 AM