Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/bin/
/target/

# Eclipse stuff
# IDE stuff
.vscode
.project
.classpath
.settings/
Expand All @@ -20,4 +21,4 @@ nbactions.xml
nbproject/

# OS stuff
.directory
.directory
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.odoojava</groupId>
<artifactId>odoo-java-api</artifactId>
<version>3.3.3</version>
<version>3.3.4</version>
<packaging>jar</packaging>

<name>odoo-java-api</name>
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/com/odoojava/api/OdooCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,26 @@ public Response searchObject(String objectName, Object[] filter, int offset, int
Object offsetParam = offset < 0 ? false : offset;
Object limitParam = limit < 0 ? false : limit;
Object orderParam = order == null || order.length() == 0 ? false : order;

// TODO: Need a big refactor because it become difficult to maintain
// strategy, work with interface and factory to make the call generic in our lib and
// have specific class for eash version

// default version v17 : https://github.com/odoo/odoo/blob/17.0/odoo/models.py#L1594
// no more count parameter in the search
Object[] params = new Object[] { filter, offsetParam, limitParam, orderParam };


if (this.session.getServerVersion().getMajor() < 10){
// Before Odoo 10 there's a 'context' parameter between order and count
params = new Object[] { filter, offsetParam, limitParam, orderParam, session.getContext(), count };
}
if (this.session.getServerVersion().getMajor() >= 10 &&
this.session.getServerVersion().getMajor() < 17){
// Before Odoo 10 there's a 'context' parameter between order and count
Object[] params = (this.session.getServerVersion().getMajor() < 10)
? new Object[] { filter, offsetParam, limitParam, orderParam, session.getContext(), count }
: new Object[] { filter, offsetParam, limitParam, orderParam, count };
params = new Object[] { filter, offsetParam, limitParam, orderParam, count };
}


try {
// TODO: test differents version with search on quantity on products
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/odoojava/api/Row.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,19 @@ public int getID(){
Object idValue = get("id");
return Integer.parseInt(idValue.toString());
}


/**
* Returns the database string field of the object/row.
* @return string
*/
public String getString(String fieldName){
String res=null;
if ( get(fieldName)!= null){
res = get(fieldName).toString();
}
return res;
}

/**
* Add a listener to be notified when a row is being changed
* @param listener
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/odoojava/api/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public void startSession() throws Exception {

private void checkVersionCompatibility() throws XmlRpcException, OdooApiException {

if (this.getServerVersion().getMajor() < 8 || this.getServerVersion().getMajor() > 16) {
throw new OdooApiException("Only Odoo Version from v8.x to 16.x are maintained. "
if (this.getServerVersion().getMajor() < 8 || this.getServerVersion().getMajor() > 17) {
throw new OdooApiException("Only Odoo Version from v8.x to 17.x are maintained. "
+ "Please choose another version of the library");
}
}
Expand Down