我用xml-rpc做了请求。
List singleTasks = Arrays.asList((Object[]) objClient.execute("execute_kw",
Arrays.asList(db, uid, password, "project.task", "search_read",
Arrays.asList(Arrays.asList(
Arrays.asList("active", "=", true))),
new HashMap() {{
put("fields", Arrays.asList("display_name", "total_hours", "project_id", "user_id"));
}}
)));
遗憾的是,这会返回以下内容:
[{project_id = [Ljava.lang.Object; @ 759ebb3d,user_id = [Ljava.lang.Object; @ 484b61fc,id = 23,total_hours = 11.0,display_name = TEST}]
我不知道如何使用或转换Ljava.lang.Object,这是什么意思,我如何得到真正的id?
我认为它与字段的类型有关,因为它是one2many,many2one或many2many字段。
答案 0 :(得分:1)
我有同样的情况,我找到了这个查询。所以我决定实施回应。
假设关系是many2one,查询返回相关对象,因此必须单独进行,也就是说,必须执行以下查询(例如,对于country):
final Map<String, Object> c = (Map<String, Object>)
((Object[])models.execute("execute_kw", Arrays.asList( db, uid, password,
"project.task",
"search_read",Arrays.asList(Arrays.asList(Arrays.asList("id","=", "id_project.task"))),new HashMap<String, Object>() {{
put("fields", Arrays.asList(
"project_id"
));
}}
)))[0];
//它取值 Object [] as =(Object [])c.get(“project_id”);
问候。