30
30
import com .odoojava .api .OdooXmlRpcProxy .RPCProtocol ;
31
31
import com .odoojava .api .OdooXmlRpcProxy .RPCServices ;
32
32
import com .googlecode .jsonrpc4j .*;
33
- import com .googlecode .jsonrpc4j .JsonRpcClientException ;
34
33
35
34
/**
36
35
* *
@@ -183,11 +182,10 @@ public void startSession() throws Exception {
183
182
184
183
private void checkVersionCompatibility () throws XmlRpcException , OdooApiException {
185
184
186
- if (this .getServerVersion ().getMajor () < 8 || this .getServerVersion ().getMajor () > 15 ) {
187
- throw new OdooApiException ("Only Odoo Version from v8.x to 15 .x are maintained. "
185
+ if (this .getServerVersion ().getMajor () < 8 || this .getServerVersion ().getMajor () > 16 ) {
186
+ throw new OdooApiException ("Only Odoo Version from v8.x to 16 .x are maintained. "
188
187
+ "Please choose another version of the library" );
189
188
}
190
-
191
189
}
192
190
193
191
/**
@@ -222,12 +220,15 @@ int authenticate() throws XmlRpcException, Exception {
222
220
223
221
// JSONRPC part
224
222
try {
225
- // id = authenticate_json_rpc();
223
+ id = authenticate_json_rpc ();
226
224
System .out .println ("json rpc login" );
227
225
228
226
} catch (JsonRpcClientException e ) {
229
- System .out .println ("Json rpc issue possibly caused by https://github.com/OCA/server-tools/issues/1237" );
230
- e .printStackTrace ();
227
+ if (this .getServerVersion ().getMajor () == 10 ){
228
+ System .out .println ("ODOO 10.0 : Json rpc issue possibly caused by https://github.com/OCA/server-tools/issues/1237" );
229
+ e .printStackTrace ();
230
+ System .out .println ("ODOO 10.0 : if the trace match the issue, you could ignore this message" );
231
+ }
231
232
} catch (Throwable e ) {
232
233
System .out .println ("General exception" );
233
234
e .printStackTrace ();
@@ -246,17 +247,21 @@ private int authenticate_json_rpc() throws Throwable {
246
247
// TODO: fast and uggly implementation of json rpc, has to be refactored in the
247
248
// future
248
249
249
- Map < String , String > articleMapOne = new HashMap <>( );
250
- articleMapOne . put ( "password" , password );
251
- articleMapOne .put ("login " , userName );
252
- articleMapOne .put ("db " , databaseName );
250
+ jsonclient . setServiceUrl ( getJsonurl ( "jsonrpc" ) );
251
+ Map < String , Object > jsonparams = new HashMap <>( );
252
+ jsonparams .put ("service " , "common" );
253
+ jsonparams .put ("method " , "login" );
253
254
254
- // Object[] result = call_json_rpc(, "common", "login", articleMapOne);
255
+ ArrayList <Object > methodparams = new ArrayList <>();
256
+ methodparams .add (databaseName );
257
+ methodparams .add (userName );
258
+ methodparams .add (password );
259
+ jsonparams .put ("args" , methodparams );
255
260
256
- jsonclient .setServiceUrl ( getJsonurl ( "web/session/authenticate" ) );
261
+ int result = jsonclient .invoke ( "call" , jsonparams , int . class );
257
262
258
- Map < String , Object > result = jsonclient . invoke ( "call" , articleMapOne , HashMap . class ) ;
259
- return ( int ) result . get ( "uid" );
263
+ return ( int ) result ;
264
+
260
265
}
261
266
262
267
public Object [] call_report_jsonrpc (String reportModel , String reportMethod , ArrayList <Object > args )
0 commit comments