DeBortoliWines / openerp-java-api

A Java API to connect to OpenERP and manage data using the XMLRPC interface.
Apache License 2.0
38 stars 71 forks source link

Filter by Null Field #30

Closed Masterz90 closed 7 years ago

Masterz90 commented 8 years ago

Filtering by Null Field using false value throws a NumbericFormatException is this the correct behavior? if so , then how to correctly filter by null.

               ObjectAdapter adapter = PosData.session.getObjectAdapter("product.product");
                FilterCollection filter = new FilterCollection();
                filter.add("company_id","=","false");
flotho commented 7 years ago

Hi, I'm not sure of what you're trying to do. As you said, filtering on null is forbidden. Apache XMLRPC prevent this an empty array has to be passed. First case, if you need to make a search on all the model class you could pass an empty array as parameter. The proper way to deal with this is :

command.searchObject("ir.model", new Object[]{});

Now, regarding to the code you posted, I'm not sure that it's what you're trying to do. Do you want to filter on partners that are not company_id. If it's the case, you mustn't use "false". In java false is legal but not in python. So try :

filter.add("company_id","=", false);
//OR
filter.add("company_id","=","False");

You could also try one of those operators : https://github.com/DeBortoliWines/openerp-java-api/blob/master/src/main/java/com/debortoliwines/odoo/api/helpers/FilterHelper.java#L40

Let me know