تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
14718 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أغسطس 17
15982
1
نوفمبر 18
5471
2
أبريل 20
4204
1
نوفمبر 17
4423
1
سبتمبر 15
5184