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 to call action_invoice_create of Openerp with XMLRPC?

By
Anna
on 8/4/14, 11:54 AM 1,694 views

Hi! i am creating an android client for the sales module and i want to call action_invoice_create function to create and invoice of a sale.order, i'm calling the function like this:   

public Integer create_invoice(String model, Integer[] ids) {
        Integer id = 0;
        try {
            XMLRPCClient client = new XMLRPCClient(mUrl);
            id = (Integer)client.call("execute", mDatabase, mUserId, mPassword, "sale.order", "action_invoice_create", ids);
        } catch (XMLRPCException e) {
            Log.d(CONNECTOR_NAME, e.toString());
        }
        return id;
    }

 

But it gives me this error when i call it:

08-04 11:50:03.074    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ android.os.NetworkOnMainThreadException
08-04 11:50:03.074    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
08-04 11:50:03.074    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
08-04 11:50:03.084    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
08-04 11:50:03.094    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at libcore.io.IoBridge.connect(IoBridge.java:112)
08-04 11:50:03.094    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
08-04 11:50:03.094    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
08-04 11:50:03.094    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at java.net.Socket.connect(Socket.java:843)
08-04 11:50:03.104    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
08-04 11:50:03.104    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
08-04 11:50:03.104    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-04 11:50:03.114    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-04 11:50:03.114    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
08-04 11:50:03.114    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-04 11:50:03.124    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-04 11:50:03.124    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-04 11:50:03.124    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:178)
08-04 11:50:03.124    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:447)
08-04 11:50:03.124    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at appact.OpenErpConnect.create_invoice(OpenErpConnect.java:325)
08-04 11:50:03.134    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at eficiatech.pantera.panteradefinit.Presupuestos$1.onClick(Presupuestos.java:95)
08-04 11:50:03.134    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.view.View.performClick(View.java:4438)
08-04 11:50:03.144    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.view.View$PerformClick.run(View.java:18422)
08-04 11:50:03.144    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
08-04 11:50:03.144    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
08-04 11:50:03.154    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.os.Looper.loop(Looper.java:136)
08-04 11:50:03.154    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5017)
08-04 11:50:03.154    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
08-04 11:50:03.154    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
08-04 11:50:03.164    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-04 11:50:03.164    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-04 11:50:03.164    1687-1687/eficiatech.pantera.panteradefinit W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
08-04 11:50:03.164    1687-1687/eficiatech.pantera.panteradefinit D/OpenErpConnect﹕ xmlrpc.android.XMLRPCException: android.os.NetworkOnMainThreadException

Anna, I dont think this is an error due to OpenERP. This seems more like a nativemethod/network error on your android. I wonder why you convert the result of method into integer! Did you check server-side traceif a call is made?

Serpent Consulting Services Pvt. Ltd.
on 8/4/14, 1:37 PM

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

2 follower(s)

Stats

Asked: 8/4/14, 11:54 AM
Seen: 1694 times
Last updated: 3/16/15, 8:10 AM