Skip to content

Commit 7f8b827

Browse files
authored
Merge pull request #26 from odoo-java/16.0-MIG-API-TRY2
[WIP][MIG][16.0]Odooo 16
2 parents 183fe11 + f057b8b commit 7f8b827

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,17 @@ saveToDatabaseForTrackingPurpose(newPartner.getID());
118118

119119
* https://sourceforge.net/p/openerpjavaapi/wiki/Dependencies/
120120
* https://sourceforge.net/p/openerpjavaapi/wiki/Examples/
121+
122+
123+
# Known bugs
124+
125+
Since v14, the render method is now private.
126+
So printing is no more possible with rpc call.
127+
For the references :
128+
* https://github.com/odoo/odoo/issues/78528
129+
* https://github.com/OCA/odoorpc/issues/65
130+
131+
A workaround is to create a module to make the render method public until we implement this method https://github.com/OCA/odoorpc/issues/88#issuecomment-1907870776
132+
a better workaround is to propose a PR in this repo to implement the missing part
133+
134+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.odoojava</groupId>
77
<artifactId>odoo-java-api</artifactId>
8-
<version>3.2.2</version>
8+
<version>3.3.3</version>
99
<packaging>jar</packaging>
1010

1111
<name>odoo-java-api</name>

src/main/java/com/odoojava/api/Session.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.odoojava.api.OdooXmlRpcProxy.RPCProtocol;
3131
import com.odoojava.api.OdooXmlRpcProxy.RPCServices;
3232
import com.googlecode.jsonrpc4j.*;
33-
import com.googlecode.jsonrpc4j.JsonRpcClientException;
3433

3534
/**
3635
* *
@@ -183,11 +182,10 @@ public void startSession() throws Exception {
183182

184183
private void checkVersionCompatibility() throws XmlRpcException, OdooApiException {
185184

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. "
188187
+ "Please choose another version of the library");
189188
}
190-
191189
}
192190

193191
/**
@@ -222,12 +220,15 @@ int authenticate() throws XmlRpcException, Exception {
222220

223221
// JSONRPC part
224222
try {
225-
// id = authenticate_json_rpc();
223+
id = authenticate_json_rpc();
226224
System.out.println("json rpc login");
227225

228226
} 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+
}
231232
} catch (Throwable e) {
232233
System.out.println("General exception");
233234
e.printStackTrace();
@@ -246,17 +247,22 @@ private int authenticate_json_rpc() throws Throwable {
246247
// TODO: fast and uggly implementation of json rpc, has to be refactored in the
247248
// future
248249

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");
253254

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+
//TODO : maybe also use the same syntax as reporting
260+
jsonparams.put("args", methodparams);
255261

256-
jsonclient.setServiceUrl(getJsonurl("web/session/authenticate"));
262+
int result = jsonclient.invoke("call", jsonparams, int.class);
257263

258-
Map<String, Object> result = jsonclient.invoke("call", articleMapOne, HashMap.class);
259-
return (int) result.get("uid");
264+
return (int) result;
265+
260266
}
261267

262268
public Object[] call_report_jsonrpc(String reportModel, String reportMethod, ArrayList<Object> args)
@@ -275,12 +281,20 @@ public Object[] call_report_jsonrpc(String reportModel, String reportMethod, Arr
275281
methodparams.add(password);
276282
methodparams.add(reportModel);
277283
methodparams.add(reportMethod);
278-
methodparams.add(args);
279284

285+
ArrayList<Object> empty_recordset_for_model_annotation_in_odoo = new ArrayList<>();
286+
//The render method is annotated @model in Odoo, so we must pass an empty value as the first
287+
//paramter otherwise Odoo will only interpret 1 parameter from the 2 given
288+
//TODO: find a way to identify if a metho is annotated with @api.model
289+
args.add(0, empty_recordset_for_model_annotation_in_odoo );
290+
methodparams.add(args);
280291
jsonparams.put("args", methodparams);
281-
282292
Object[] result = jsonclient.invoke("call", jsonparams, Object[].class);
283293

294+
// methodparams.add(args);
295+
// jsonparams.put("args", methodparams);
296+
// Object[] result = jsonclient.invoke("call", jsonparams, Object[].class);
297+
284298
return result;
285299

286300
}

0 commit comments

Comments
 (0)