Skip to content

Commit 4eaf6aa

Browse files
authored
Merge pull request #29 from odoo-java/v17.0
[MIG]Add Odoo17 Support
2 parents 7f8b827 + 1056f79 commit 4eaf6aa

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
/bin/
44
/target/
55

6-
# Eclipse stuff
6+
# IDE stuff
7+
.vscode
78
.project
89
.classpath
910
.settings/
@@ -20,4 +21,4 @@ nbactions.xml
2021
nbproject/
2122

2223
# OS stuff
23-
.directory
24+
.directory

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

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.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

Lines changed: 19 additions & 3 deletions
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/Row.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,19 @@ public int getID(){
6767
Object idValue = get("id");
6868
return Integer.parseInt(idValue.toString());
6969
}
70-
70+
71+
/**
72+
* Returns the database string field of the object/row.
73+
* @return string
74+
*/
75+
public String getString(String fieldName){
76+
String res=null;
77+
if ( get(fieldName)!= null){
78+
res = get(fieldName).toString();
79+
}
80+
return res;
81+
}
82+
7183
/**
7284
* Add a listener to be notified when a row is being changed
7385
* @param listener

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

Lines changed: 2 additions & 2 deletions
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)