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

Hi All,

I have 3 classes (say class1, class2, class3). In class1, I have a checkbox (say cb1) and a many2one field (say field1). If the check box is True, the many2one field must load data from class2 (fields.many2one('class2','field1')). if checkbox is False, the many2one field must load data from class3 (fields.many2one('class3','field1')). Is it possible. Please help me with a solution. Thank you in advance.

 

 

Regards,

Emon.

 

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

Based on your requirement form view add  two different class many2one field. Based on condition hide one and shows others.

Example,

'class2_id':fields.many2one('table1', 'Table1'),

'class3_id:fields.many2one('table2', 'Table2'),

<field name="class2_id" attrs="{'invisible':[('ischeck','=',False)]}"/>

<field name="class3_id" attrs="{'invisible':[('ischeck','=',True)]}"/>

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

Thank you for the answer Prakash. But In my scenerio, I have only one field which must be linked with multiple classes. It must be saved in the single column in the table.

Ảnh đại diện
Huỷ bỏ

In single column using domain you can filter value.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 25
6070
1
thg 12 24
1565
1
thg 11 22
16130
3
thg 8 22
13240
2
thg 8 22
4636