This question has been flagged
1 Reply
12934 Views

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
Discard
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
Discard