Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
866 Tampilan

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 ,

Avatar
Buang
Jawaban Terbai

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! 

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
4
Okt 21
79897
1
Nov 20
4449
0
Okt 17
4827
1
Agu 23
3180
0
Nov 21
2270