@@ -78,11 +78,16 @@ public Response searchObject(String objectName, Object[] filter, int offset, int
7878 Object orderParam = order == null || order .length () == 0 ? false : order ;
7979 // Before Odoo 10 there's a 'context' parameter between order and count
8080 Object [] params = (this .session .getServerVersion ().getMajor () < 10 )
81- ? new Object []{filter , offsetParam , limitParam , orderParam , false , count }
81+ ? new Object []{filter , offsetParam , limitParam , orderParam , session . getContext () , count }
8282 : new Object []{filter , offsetParam , limitParam , orderParam , count };
8383
8484 try {
85- Response response = new Response (session .executeCommand (objectName , "search" , params ));
85+ //TODO: test differents version with search on quantity on products
86+ //with location_id in the context to check that it works or not
87+ Response response = (this .session .getServerVersion ().getMajor () < 10 )
88+ ? new Response (session .executeCommand (objectName , "search" , params ))
89+ : new Response (session .executeCommandWithContext (objectName , "search" , params ));
90+
8691 return response ;
8792 } catch (XmlRpcException e ) {
8893 return new Response (e );
@@ -100,7 +105,7 @@ public Response searchObject(String objectName, Object[] filter, int offset, int
100105 @ SuppressWarnings ("unchecked" )
101106 public Map <String , Object > getFields (String objectName , String [] filterFields ) throws XmlRpcException {
102107 Map <String , Object > fieldsArray ;
103- if (this .session .getServerVersion ().getMajor () >= 8 ) {
108+ if (this .session .getServerVersion ().getMajor () >= 8 ) {
104109 fieldsArray = (Map <String , Object >) session .executeCommand (objectName , "fields_get" ,
105110 new Object []{filterFields });
106111 } else {
@@ -122,13 +127,14 @@ public Map<String, Object> getFields(String objectName, String[] filterFields) t
122127 * @throws XmlRpcException
123128 */
124129 public Object [] readObject (String objectName , Object [] ids , String [] fields ) throws XmlRpcException {
125- Object [] readResult ;
126- if (this .session .getServerVersion ().getMajor () >= 8 ) {
127- readResult = (Object []) session .executeCommand (objectName , "read" , new Object []{ids , fields });
130+ Object [] readResult ;
131+ if (this .session .getServerVersion ().getMajor () >= 8 ) {
132+ readResult = (Object []) session .executeCommandWithContext (objectName , "read" , new Object []{ids , fields });
128133 } else {
134+ //TODO: Have to be rewritten/deleted considering the previous call
129135 readResult = (Object []) session .executeCommand (objectName , "read" , new Object []{ids , fields , session .getContext ()});
130136 }
131-
137+
132138 return readResult ;
133139 }
134140
@@ -142,7 +148,15 @@ public Object[] readObject(String objectName, Object[] ids, String[] fields) thr
142148 * @throws XmlRpcException
143149 */
144150 public boolean writeObject (String objectName , int id , Map <String , Object > valueList ) throws XmlRpcException {
145- return (Boolean ) session .executeCommand (objectName , "write" , new Object []{id , valueList });
151+ if (this .session .getServerVersion ().getMajor () < 10 ) {
152+ //Prior to the v10, each version have to be adapted if needed
153+ //Some methods on certains class from v8 to v9 don't respect the syntax
154+ return (Boolean ) session .executeCommand (objectName , "write" , new Object []{id , valueList });
155+ } else {
156+ //Work perfectly for the v10, please keep this check
157+ return (Boolean ) session .executeCommandWithContext (objectName , "write" , new Object []{id , valueList });
158+ }
159+
146160 }
147161
148162 /**
@@ -202,16 +216,15 @@ public boolean unlinkObject(String objectName, Object[] ids) throws XmlRpcExcept
202216 * @throws XmlRpcException
203217 */
204218 public Object createObject (String objectName , Map <String , Object > values ) throws XmlRpcException {
205- Object readResult ;
206- if (this .session .getServerVersion ().getMajor () >= 8 ) {
219+ Object readResult ;
220+ if (this .session .getServerVersion ().getMajor () < 10 ) {
207221 readResult = (Object ) session .executeCommand (objectName , "create" , new Object []{values });
208222 } else {
209- readResult = (Object ) session .executeCommand (objectName , "create" , new Object []{values , session . getContext () });
223+ readResult = (Object ) session .executeCommandWithContext (objectName , "create" , new Object []{values });
210224 }
211-
225+
212226 return readResult ;
213-
214-
227+
215228 }
216229
217230 /**
0 commit comments