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

I am trying to insert a record into product.attribute.line (Odoo 9), the record created but the values of field(many2many field) value_ids are not there. Can anybody help? The following are my codes. Note: value and product_tmpl_id exists in corresponding tables.


HashMap colInfo = new HashMap();

colInfo.put("attribute_id", "1");

colInfo.put("name", color);

int value=getObjectID("product.attribute.value", color, colInfo , true);

int product_tmpl_id = getObjectID("product.template", name, proInfo, true);

HashMap lineMP = new HashMap();

lineMP.put("product_tmpl_id", product_tmpl_id);

lineMP.put("attribute_id", "1");

// lineMP.put("value_ids", Arrays.asList("(4, "+Arrays.asList(value)+")"));

// lineMP.put("value_ids", Arrays.asList("(0, 0,"+Arrays.asList(value)+")"));

//  lineMP.put("value_ids", Arrays.asList("(6, 0,"+Arrays.asList(value)+")"));

lineMP.put("value_ids", Arrays.asList(Arrays.asList("6", "0",Arrays.asList(value))));




Avatar
Discard
Author Best Answer

I have gotten the answer,the following is correct:

lineMP.put("value_ids", Arrays.asList(Arrays.asList(6, 0,Arrays.asList(value))));

Avatar
Discard