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

Can I use both required and invisible attributes in same field and same attrs like below in odoo16 ? and if not possible how can I achieve this ?

<field name="iwave_bill_to" attrs="{
'required': [('move_type', 'in', ['out_invoice', 'out_refund', 'out_receipt'])],
'invisible': [('move_type', 'not in', ['out_invoice', 'out_refund', 'out_receipt'])]
}"/>

Thank you ,

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

Yes, you can use both required and invisible attributes in the same field. Use tuples () instead of lists [].

<field name="iwave_bill_to" attrs="{
'required': [('move_type', 'in', ('out_invoice', 'out_refund', 'out_receipt'))],
'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]
}"/>

For some cases, I would rather use a boolean field with a compute. 

I hope this helps! 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 10 21
80038
1
thg 11 20
4526
0
thg 10 17
4899
1
thg 8 23
3286
0
thg 11 21
2366