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

Hello guys,
i need to show a field on hr application form only when an application is on 2 specific stages.

I created this code but it's not working:

 {"invisible": ["&",["stage_id","=","Phase1"],["stage_id","=","Phase2"]]}

Phase1 and Phase2 are phases names.
Any ideas?
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Its not a best practice to do comparison using the name, if you can add any other boolean marker in the stag level and using that if you tried to achieve it will be better.

Anyway, here you may have to add a related field of stage name in your hr.application model and then based on it, you have to compare.

stage_name = fields.Char(related='stage_id.name')

XML:

 attrs="{'invisible': [('stage_name', 'in', ('Phase1', 'Phase2'))]}"


Thanks

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

Thanks for the support.

I found a solution by referrinf not to stage names but to stage ids.

The code to add to xml file is:

{"invisible": ["&",["stage_id","!=",4],["stage_id","!=",5]]}
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,
Instead of using lists, use tuples, also no need to use '&'. By default it will use the AND case.
{"invisible": [("stage_id","=","Phase1"), ("stage_id","=","Phase2")]}

Try modifying the code like this.

Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 23
2684
2
thg 6 23
2221
0
thg 4 21
1587
3
thg 2 21
17630
4
thg 10 20
6707