Closed vicdoz closed 5 years ago
I have the same problem, i am trying to fix it for days now, every time i got a null return on th search method. May be someone should rewrite this method.
after some further testing and brek points in the code , i got the root exception :+1:
W/System.err(13086): java.lang.ClassCastException: java.lang.String
W/System.err(13086): at org.xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:317)
W/System.err(13086): at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:377)
System.err(13086): at gestge.utilities.OpenErpConnect.search(OpenErpConnect.java:184) <----------
W/System.err(13086): at gestge.utilities.OpenErpConnect.search(OpenErpConnect.java:148) <----------
the line 148 is : result = new Long[] { ((Integer)client.call("execute", parameters)).longValue() }; <---- may be thatś the source of the problème .
Hi!
First of all, please DO NOT open new issues for the same issue. There are 4 issues for the same thing...
You say that you are using it with OpenERP 7, this connector was designed to work with OpenERP 6.0. Maybe the new version works different. Those of you who have the same problem, test the connector with a 6.0 version, if it works, then you should code another connector that matches the new web services interface. I will not spend more time in this connector trying to solve this problem, as I do not work with it anymore.
Once tryied what I told you, please provide feedback saying if it's a problem with the newer versions.
Cheers.
joesombody: I run into similar problem and I've solved it with changing line 180 to Object[] responseIds = (Object[])client.call("execute", mDatabase, mUserId, mPassword, model, "search", conditions); I think, you can solve it with same way.
I can confirm change on line 180 works on OpenERP 7 as tvazac said. Maybe someone could test on v6 to see if it works and maybe make this change permanent.
He guys , i've also come to a solution by changing search method : this the new cpde, and its working fine with openerp 7.0
public Long[] newSearch( String model, Object[] conditions)
{
XMLRPCClient searchClient = new XMLRPCClient(mUrl);
Long[] result = null;
try
{
Object[] responseIds = (Object[])searchClient.call("execute",mDatabase,mUserId,mPassword,model,"search",conditions);
result = new Long[responseIds.length];
for (int i = 0; i < responseIds.length; i++) {
result[i] = ((Integer)responseIds[i]).longValue();
}
}
catch(Exception e)
{
Log.i("Search a encore echoue !", e.toString());
}
return result;
}
Thank a lot, @zahidj your code works fine and just saved me after hours of pain. Should be pushed to the project!
Could someone confirm that this change doesn't break compatibility for OpenERP v6 so the repo could be updated safely?
Enric Caumons El 16/11/2013 14:20, "Christophe Versieux" notifications@github.com escribió:
Thank a lot, @zahidj https://github.com/zahidj your code works fine and just saved me after hours of pain. Should be pushed to the project!
— Reply to this email directly or view it on GitHubhttps://github.com/zikzakmedia/android-openerp/issues/4#issuecomment-28626324 .
help me ?
Object[] ids = (Object[]) oc.search("project.task",new Object[] {new Object[] {"project_id", "=", "101"}});
for (Object obj : ids) {
int a = Integer.parseInt(obj.toString());
System.out.println(a);
}
result empty
@zahidj you are a life saver, any ideas why connection seems to fail when i go to different activity?
Hi @UannaFF , In the case your application has many activities. The connection object returned by this class, should be accesible by all of them. You can performe this by many ways:
I thonk that this issue is solved and then should be closed.
Hi,I try use your android-openerp class but i have an issue. I'm using OpenErp v7 My code:
OpenErpConnect x=OpenErpConnect.login(servername, port_server, db_name,username, pass); Long[] ids = x.search("res.partner",true, new Object[0]); System.out.println("IDS="+ids);
servername, port_server, db_name, username and pass are correctly defined.I can connect with my openerp perfectly. I can execute the methods of read or write(if you know the ids) and works! , but when i try searching the ids happens this:
01-10 11:38:18.833: W/System.err(1028): java.io.IOException: Cannot serialize null 01-10 11:38:18.833: W/System.err(1028): at org.xmlrpc.android.XMLRPCSerializer.serialize(XMLRPCSerializer.java:99) 01-10 11:38:18.843: W/System.err(1028): at org.xmlrpc.android.XMLRPCSerializer.serialize(XMLRPCSerializer.java:61) 01-10 11:38:18.853: W/System.err(1028): at org.xmlrpc.android.XMLRPCCommon.serializeParams(XMLRPCCommon.java:36) 01-10 11:38:18.863: W/System.err(1028): at org.xmlrpc.android.XMLRPCClient.methodCall(XMLRPCClient.java:250) 01-10 11:38:18.874: W/System.err(1028): at org.xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:170) 01-10 11:38:18.874: W/System.err(1028): at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:281)
01-10 11:38:18.883: W/System.err(1028): at packet.OpenErpConnect.search(OpenErpConnect.java:184) 01-10 11:38:18.883: W/System.err(1028): at packet.OpenErpConnect.search(OpenErpConnect.java:153)
01-10 11:38:18.883: W/System.err(1028): at packet.MainActivity$1.onClick(MainActivity.java:66) 01-10 11:38:18.893: W/System.err(1028): at android.view.View.performClick(View.java:3511) 01-10 11:38:18.893: W/System.err(1028): at android.view.View$PerformClick.run(View.java:14105) 01-10 11:38:18.913: W/System.err(1028): at android.os.Handler.handleCallback(Handler.java:605) 01-10 11:38:18.913: W/System.err(1028): at android.os.Handler.dispatchMessage(Handler.java:92) 01-10 11:38:18.913: W/System.err(1028): at android.os.Looper.loop(Looper.java:137) 01-10 11:38:18.913: W/System.err(1028): at android.app.ActivityThread.main(ActivityThread.java:4424) 01-10 11:38:18.933: W/System.err(1028): at java.lang.reflect.Method.invokeNative(Native Method) 01-10 11:38:18.933: W/System.err(1028): at java.lang.reflect.Method.invoke(Method.java:511) 01-10 11:38:18.953: W/System.err(1028): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 01-10 11:38:18.964: W/System.err(1028): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 01-10 11:38:18.973: W/System.err(1028): at dalvik.system.NativeStart.main(Native Method) 01-10 11:38:18.983: D/OpenErpConnect(1028): org.xmlrpc.android.XMLRPCException: java.io.IOException: Cannot serialize null 01-10 11:38:18.983: I/System.out(1028): IDS=null
the line 184: Method Search: if (count) { // We just want the number of items result = new Long[] { ((Integer)client.call("execute", parameters)).longValue() };<----.------THIS } else { // Returning the list of matching item id's
the line 153
You add a parameter with value=null: parameters.add(null);
this null is the problem? another parameters in theory aren't null....
Cheers!