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

I need some field to be invisible if 3 conditions are met


How do I express that ?

I tried putting the '&' before, in between, several times, one time


It never works


Thanks

形象
丢弃
编写者

I want to make more precise statements

I have this combination


attrs="{'invisible': [('firstField '!=', 'somevalueForFirstField'),
('secondField', '!=', 'someValueForSecondField'),
('thirdField','=',False)]}"

I want these 3 conditions to be in and

They are not

Only the third one is being applied

最佳答案

By default '&' is applied. this code should work if what you want is all these conditions to be true at the same time. But if you want either of this condition to be true, then use '|' instead. Then the syntax would be ['|','|',A,B,C].

I have noticed that in your sample code your are putting field in '' . Don't do that, write field name without '' , the same as you did for False.

So your code would be

attrs="{'invisible': [('firstField '!=', somevalueForFirstField),
('secondField', '!=', someValueForSecondField),
('thirdField','=',False)]}"


形象
丢弃
最佳答案

Hello,

'|' and '&' can be a little tricky.

Assuming you are on Odoo14, the correct way with 2 elements in your code would be:

attrs="{'invisible': ['&', 
                      ('firstField '!=', 'somevalueForFirstField'),
('secondField', '!=', 'someValueForSecondField')
]}"

So i haven't tryed but maybe the third one needs another '&' in between the second and third element or the first and the second?


形象
丢弃
相关帖文 回复 查看 活动
0
2月 25
557
2
6月 24
1840
1
6月 19
5714
1
1月 17
3605
0
3月 15
5047