Skip to content

Commit 557c0a7

Browse files
committed
[IMP]Add Odoo 17 support
[IMP]Bump version
1 parent 72bf139 commit 557c0a7

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

pom.xml

+1-1
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.3.3</version>
8+
<version>3.3.4</version>
99
<packaging>jar</packaging>
1010

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

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

+19-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,26 @@ public Response searchObject(String objectName, Object[] filter, int offset, int
7676
Object offsetParam = offset < 0 ? false : offset;
7777
Object limitParam = limit < 0 ? false : limit;
7878
Object orderParam = order == null || order.length() == 0 ? false : order;
79+
80+
// TODO: Need a big refactor because it become difficult to maintain
81+
// strategy, work with interface and factory to make the call generic in our lib and
82+
// have specific class for eash version
83+
84+
// default version v17 : https://github.com/odoo/odoo/blob/17.0/odoo/models.py#L1594
85+
// no more count parameter in the search
86+
Object[] params = new Object[] { filter, offsetParam, limitParam, orderParam };
87+
88+
89+
if (this.session.getServerVersion().getMajor() < 10){
90+
// Before Odoo 10 there's a 'context' parameter between order and count
91+
params = new Object[] { filter, offsetParam, limitParam, orderParam, session.getContext(), count };
92+
}
93+
if (this.session.getServerVersion().getMajor() >= 10 &&
94+
this.session.getServerVersion().getMajor() < 17){
7995
// Before Odoo 10 there's a 'context' parameter between order and count
80-
Object[] params = (this.session.getServerVersion().getMajor() < 10)
81-
? new Object[] { filter, offsetParam, limitParam, orderParam, session.getContext(), count }
82-
: new Object[] { filter, offsetParam, limitParam, orderParam, count };
96+
params = new Object[] { filter, offsetParam, limitParam, orderParam, count };
97+
}
98+
8399

84100
try {
85101
// TODO: test differents version with search on quantity on products

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ public void startSession() throws Exception {
182182

183183
private void checkVersionCompatibility() throws XmlRpcException, OdooApiException {
184184

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. "
185+
if (this.getServerVersion().getMajor() < 8 || this.getServerVersion().getMajor() > 17) {
186+
throw new OdooApiException("Only Odoo Version from v8.x to 17.x are maintained. "
187187
+ "Please choose another version of the library");
188188
}
189189
}

0 commit comments

Comments
 (0)