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

I have two one2many fields and every field in the separate view ,

I need  when i fill data in the first  one2many field click on button to take the data from one2many  in view A

and fill it in the second one2many in view B

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

you have to update values of one2many B using some format.

Have a look here one2many flags

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

First of all if you have 2 o2m relations with the same data you should re evaluate your data model. But filling o2m fields is done like in Hilar link, but this copy paste from the odoo documentation sux when you don't know what you're doing!

So if you you want so fill the model on the "many" side you need a dict of values that you just pass to the field that has the relation on the "one" side of the relation.

# field with the o2m relation
relation_ids = fields.One2Many()

# filling the many model
relation_ids = [(0, 0, dict_of_values)]

# OR
relation_ids = [(0, 0, {'field1': self.value1, 'field2': value2})]  
Ảnh đại diện
Huỷ bỏ

I am trying this but its not working. The tree view is not showing the new data

It works, you have to got a different problem. Check in the database if there is the data. If there is data then it was inserted. If you cannot get it to work, just ask a question and paste your code.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 21
8500
0
thg 6 23
109
4
thg 11 16
6062
1
thg 5 24
2522
3
thg 3 15
5568