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

Hi There. How can I hide a field based on context in Odoo 18? I do not want to use an additional boolean field for this, but make it directly with the context.

Thank you in advance!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Please refer to the code below:

<record id="custom_model" model="ir.actions.act_window">
<field name="name">Custom Model</field>
<field name="res_model">custom.model</field>
<field name="view_mode">kanban,list,form,activity,pivot,graph,cohort</field>
<field name="domain"></field>
<field name="context">{'default_custom_context_field': True}</field>
<field name="help" type="html">

</field>
</record>

Invisible field:

<field name="custom_field" invisible="context.get('default_custom_context_field')"/>

Hope it helps.

อวตาร
ละทิ้ง
ผู้เขียน

This worked perfectly, thank you!