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

Cast exception with callObjectFunction of OpenErpCommand #18

Closed JurassicPork closed 9 years ago

JurassicPork commented 9 years ago

hello, i try to execute the function attendance_action_change of hr.employee object (hr_attendance.py). with the following code seems to be ok but i have this exception : java.lang.Boolean cannot be cast to [Ljava.lang.Object; java.lang.ClassCastException: java.lang.Boolean cannot be cast to [Ljava.lang.Object; at com.debortoliwines.openerp.api.OpenERPCommand.callObjectFunction(OpenERPCommand.java:171)

the code : try { OpenERPCommand MaCommande = new OpenERPCommand(openERPSession); Object[] params = new Object[] {1}; MaCommande.callObjectFunction("hr.employee","attendance_action_change",params);

} catch (Exception e) { System.out.println("Error while reading data from server:\n\n" + e.getMessage() ); e.printStackTrace(); }

the end of the function attendance_action_change is "return true"

Another way to execute attendance_action_change ?

JurassicPork commented 9 years ago

Found a solution in the file OpenERPCommand.java i have created a new function : public Boolean callObjectFunctionBoolean(String objectName, String functionName, Object[] parameters) throws XmlRpcException { return (Boolean) session.executeCommand(objectName, functionName, parameters); }

i have now no exception with this code : System.out.println(MaCommande.callObjectFunctionBoolean("hr.employee","attendance_action_change",params).toString()); display True.

flotho commented 9 years ago

Hi @JurassicPork ,

great proposal. I add it in the wishlist. Purpose will be to ease the managemnt of non native Odoo method