This question has been flagged
3 Replies
5501 Views

Guys please help this is my code 

Object[] l = { "is_company", "=", false }; 
Object[] filter = { l };
odoo = new OdooUtility("http://10.10.35.7:8069", "object"); 
SearchIdTask = odoo.exec(listner, "db","1","password","res.partner","search",filter);
and here is the exec method
public Long exec (XMLRPCCallback listner, String db, String uid, String password,String objects, String method, Object[] data){    
Long id = client.callAsync(listner,"execute_kw",db,Integer.parseInt(uid),password,objects,method,data);
return id;
}
Avatar
Discard
Author

pls I've been looking at this for hours i think there is something wrong with the filter :'(

Author Best Answer

Thank you so much for your answer but i still get the same error, i'm affraid if i try the second code it wont work bc xmlrpc in android doesn't work well because i'm using a light weight library called aXMLRPC that was develppd by someone in github

Avatar
Discard
Best Answer

Hi Hanane,

In your code Object Array should be define as follow:

Object[] l = new Object[]{ "is_company", "=", false};
Object[] filter = new Object[]{l};

You can try following working code for java :

package odoo.java;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class JavaOdoo {
public static void main(String[] args){
final XmlRpcClient client = new XmlRpcClient();
Object[] emptyList = new Object[]{};
final String url = "http://192.168.153.128:8069";
final String db = "demo_80";
final String username = "admin";
final String password = "a";
System.out.print("Hello World");
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
try {
common_config.setServerURL(
new URL(String.format("%s/xmlrpc/2/common", url)));
client.execute(common_config, "version", emptyList);
int uid = (int)client.execute(
common_config, "authenticate", new Object[]{db, username, password, emptyList});
System.out.print(uid);
final XmlRpcClient models = new XmlRpcClient() {{
setConfig(new XmlRpcClientConfigImpl() {{
setServerURL(new URL(String.format("%s/xmlrpc/2/object", url)));
}});
}};
Object[] res = (Object[]) models.execute("execute_kw", new Object[]{
db, uid, password,
"res.partner", "search",
new Object[]{new Object[]{
new Object[]{"is_company", "=", false}}}
});
                         // printing ids of partner which have is_company false.
for(int i=0;i<res.length;i++){
System.out.println(res[i]);
}
} catch (XmlRpcException | MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



Regards,

Hardikgiri Goswami

 

Avatar
Discard