Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3606 มุมมอง

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?


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ส.ค. 25
7
0
ก.พ. 25
705
Removeing attrs in 17.0 แก้ไขแล้ว
2
มิ.ย. 24
2058
1
มิ.ย. 19
5851
1
ม.ค. 17
3748