Bantuan

1

Insert multiple new values into one2many / many2many Odoo v8, v9, v10...

Avatar
Reinhart

Hi, with o2m_field = [(0, 0, dict)] you add a new record created with 'dict' values, but i want to create a entire tree structure with only 1 create method, how should i insert multiple childs in the dict?

Some examples / tries i'm testing:


dict = {
'name': 'TREE ROOT',
'child_id': [
(0, 0, [
{'name': 'A1'},
{'name': 'A2', 'child_id': [(0, 0, {'name': 'B1'})]}
])
]
}

dict = {
'name': 'TREE ROOT',
'child_id': [
(0, 0, [{'name': 'A1'}]),
(0, 0, [{'name': 'A2', 'child_id': [(0, 0, {'name': 'B1'})]}])
]
}

Is some of those correct to achieve it?

It should be: [(0,0,list_of_dicts)] or [list_of_(0,0,dict)] or list_of_[(0,0,dict)] ?

Avatar
Abaikan
1Jawaban
6
Best Answer

Hi,

See the sample here,


order_lines = []
for line in test_lines:
order_lines.append((0, 0, {
'name': name,
'product_id': line.product_id.id,
'product_qty': line.product_qty,
}))
self.order_line = order_lines

Thanks

Avatar
Abaikan