I have to fetch the category a product is related to, using the read method of Odoo API. I get a list of objects, then for each category, I need to extract the field product_tmpl_ids, a list of integers. I'm not sure how to do it. This is the method:
public List readModelfields(String modelName, List<Integer> ids, List<String> fields, Integer uid) throws XmlRpcException {
List record = (List) Arrays.asList((Object[]) models.execute("execute_kw", Arrays.asList(
db, uid, password,
modelName, "read",
ids,
new HashMap() {{
put("fields", fields);
}}
)));
return record;
}
This is the rest of the code:
List<String> fields = new ArrayList<>();
fields.add("product_tmpl_ids");
List categoryIds = (List<Integer>)service.searchByStrParameter("product.public.category", "name", "A - Administration / Office", uid);
List result = (List)service.readModelfields("product.public.category", categoryIds, fields, uid);
Can anybody help? How to extract the fields from the fetched objects?