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.

0

How do I put XMLRPC parameters to list record

By
IGAM Muliarsa
on 4/14/15, 10:56 PM 1,582 views

anyone can help me to put XMLRPC parameters to list record?

I wrote this method and change the parameters from :

asList((Object[])models.execute("execute_kw", asList(
db, uid, password,
"res.partner", "search",
asList(asList(
asList("is_company", "=", true),
asList("customer", "=", true)))
)));

 to 

Object[] paramsMethod = new Object[]{
new Object[] {"is_company", "=", true},
new Object[] {"customer", "=", true}
};
Object[] params = new Object[] {db, uid, password, resource, action, paramsMethod};
Object result = client.execute("execute_kw", params);
System.out.println("done");

and error arise:

Exception in thread "main" org.apache.xmlrpc.XmlRpcException: Traceback (most recent call last):

File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 75, in xmlrpc_return

result = openerp.http.dispatch_rpc(service, method, params)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 114, in dispatch_rpc

result = dispatch(method, params)

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 37, in dispatch

res = fn(db, uid, *params)

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 162, in execute_kw

return execute(db, uid, obj, method, *args, **kw or {})

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper

return f(dbname, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 170, in execute

res = execute_cr(cr, uid, obj, method, *args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 159, in execute_cr

return getattr(object, method)(cr, uid, *args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1639, in search

return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/addons/base/res/res_partner.py", line 656, in _search

count=count, access_rights_uid=access_rights_uid)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4621, in _search

query = self._where_calc(cr, user, args, context=context)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4438, in _where_calc

if not any(item[0] == 'active' for item in domain):

File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4438, in <genexpr>

if not any(item[0] == 'active' for item in domain):

TypeError: 'bool' object has no attribute '__getitem__'

at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)

at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)

at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)

at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)

at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)

at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)

at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)

at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)

at TutorialLocal.listRecord(TutorialLocal.java:193)

at TutorialLocal.main(TutorialLocal.java:81)

This is the method:

static Object listRecord(int uid, String url, String db, String username, String password, String resource, String action) throws MalformedURLException, XmlRpcException {
      XmlRpcClient client = new XmlRpcClient();
      XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
      config.setEnabledForExtensions(true);
      //config.setServerURL(new URL(url+"/xmlrpc/object")); // OK
      config.setServerURL(new URL(url+"/xmlrpc/2/object")); // OK
      client.setConfig(config);
      Object[] paramsMethod = new Object[]{
          new Object[] {"is_company", "=", true},
           new Object[] {"customer", "=", true}
      };
      System.out.println(resource);
      System.out.println(action);
      System.out.println(paramsMethod.toString());
      Object[] params = new Object[] {db, uid, password, resource, action, paramsMethod};
      Object result = client.execute("execute_kw", params);
      System.out.println("done");
      return result;
}

0
IGAM Muliarsa
On 4/22/15, 4:23 AM

hi.....

don worry about the question, I found the solution. please try and give correct answer. :D

public static void main(String[] args) {
    // "res.partner", "search",
    System.out.println();
    System.out.println("Search res.partner");
    System.out.println("--------------");  
    Object rLR = listRecord(uid, url, db, username, password, "res.partner", "search");
    Object[] tRLR = (Object[])rLR;
    for (int i=0;i<tRLR.length;i++) {
        System.out.println(tRLR[i]);
    }
}
static Object listRecord(int uid, String url, String db, String username, String password, String resource, String action) throws MalformedURLException, XmlRpcException {
    XmlRpcClient client = new XmlRpcClient();
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setEnabledForExtensions(true);
    //config.setServerURL(new URL(url+"/xmlrpc/object")); // OK
    config.setServerURL(new URL(url+"/xmlrpc/2/object")); // OK
    client.setConfig(config);
    Object[] paramsMethod = new Object[]{
    new Object[] {
        new Object[] {"is_company", "=", true},
        new Object[] {"customer", "=", true}
        }
    };
    HashMap<Object,Object> paramsRules = new HashMap<Object, Object>() ;
    //paramsRules.put("offset",10);
    //paramsRules.put("limit",5);
    Object[] params = new Object[] {db, uid, password, resource, action, paramsMethod, paramsRules};
    Object result = client.execute("execute_kw", params);
    return result;
}


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: 4/14/15, 10:56 PM
Seen: 1582 times
Last updated: 10/3/16, 9:58 PM