Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
981 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
4
ott 21
80022
1
nov 20
4518
0
ott 17
4896
1
ago 23
3270
0
nov 21
2355