Skip to Content
Menu
This question has been flagged
1 Reply
3265 Views

I want to get max(id) via webservice api like the following, but all failure, does anyone know how to?

"product.template", "search_read", Arrays.asList(Arrays.asList( Arrays.asList("id", "=", "max(id)") )), new HashMap() {{ put("fields", Arrays.asList("id")); }}

"product.template", "search_read", Arrays.asList(Arrays.asList( Arrays.asList("id", "=", "(select max(id) from product_template)") )), new HashMap() {{ put("fields", Arrays.asList("id")); }}

"product.template", "search_read", Arrays.asList(Arrays.asList( Arrays.asList("id", "=", "1000") )), new HashMap() {{ put("fields", Arrays.asList("id", "max(id)")); }}


Avatar
Discard
Author Best Answer

I have resolved it by myself, just for all your information.

Arrays.asList((Object[]) models.execute("execute_kw", Arrays.asList(db, uid, password, "product.template", "search_read", "", new HashMap() { { put("fields", Arrays.asList("id")); put("limit", 1); put("order", "id desc"); } })));

Avatar
Discard