Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
14719 Lượt xem

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)] ?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 17
15982
1
thg 11 18
5471
2
thg 4 20
4204
1
thg 11 17
4424
1
thg 9 15
5184