Skip to content

Commit 22e9daa

Browse files
committed
Update success case for server version 8
1 parent 0d583c3 commit 22e9daa

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ public Boolean[] writeObject(final RowCollection rows, final boolean changesOnly
854854
public boolean writeObject(final Row row, boolean changesOnly) throws OdooApiException {
855855

856856
Object idObj = row.get("id");
857+
boolean success = false;
857858

858859
if (idObj == null || Integer.parseInt(idObj.toString()) <= 0) {
859860
throw new OdooApiException("Please set the id field with the database ID of the object");
@@ -869,11 +870,32 @@ public boolean writeObject(final Row row, boolean changesOnly) throws OdooApiExc
869870

870871
try {
871872

872-
boolean success = command.writeObject(modelName, id, valueList);
873-
if (success) {
874-
row.changesApplied();
873+
if (this.serverVersion.getMajor() == 8) {
874+
Object result = command.writeObject(modelName, id, valueList);
875+
Object[] resultTemp = (Object[]) result;
876+
Object[] resultTemp2 = (Object[]) resultTemp[0];
877+
878+
if (resultTemp2[0] instanceof Boolean) {
879+
success = ((Boolean) resultTemp2[0]).booleanValue();
880+
881+
if (success) {
882+
row.changesApplied();
883+
}
884+
885+
return success;
886+
} else { // the result object is a HashMap with an exception message.
887+
return false;
888+
}
889+
890+
} else {
891+
success = (Boolean) command.writeObject(modelName, id, valueList);
892+
893+
if (success) {
894+
row.changesApplied();
895+
}
896+
897+
return success;
875898
}
876-
return success;
877899

878900
} catch (XmlRpcException e) {
879901
throw new OdooApiException(e);

0 commit comments

Comments
 (0)