跳至内容
菜单
此问题已终结
2 回复
4790 查看

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.

 

形象
丢弃
最佳答案

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)]}"/>

形象
丢弃
编写者 最佳答案

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.

形象
丢弃

In single column using domain you can filter value.

相关帖文 回复 查看 活动
2
2月 25
6098
1
12月 24
1591
1
11月 22
16139
3
8月 22
13260
2
8月 22
4641