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

It's possible hide a button with context data information. I need hide the button where the context Boolean field is False

So far i have

ctx ={'some_boolean': True,}

<button name="select_partner" type="object" string="Select" class="oe_highlight" invisible="context.get('some_boolean',False)"/>

but that hide the button in the wrong place

I need something like 

<button name="select_partner" type="object" string="Select" class="oe_highlight" attrs="{'invisible':[(context.get('some_boolean'),'!=',True)]}"/>

the second code return an error on the view.

Any sugestion

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

Instead of using the context, you can make an invisible boolean field and make the domain to invisible.

like < field name="x" invisible="1"/>

<button name="select_partner" type="object"
 string="Select" class="oe_highlight"  
attrs="{'invisible':[x,'!=',True)]}"/>


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

Hi Rafael, 
Yes you can do it. 
Just add this to your button : 

<button name="select_partner" type="object" string="Select" class="oe_highlight" invisible="context.get('some_boolean',False)"/>
อวตาร
ละทิ้ง

This not working in odoo 14

Check "view_account_analytic_line_tree_inherit_account" you will find out thats it's still used in V14.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 23
3250
0
พ.ย. 21
2334
Attrs multiple condition. Boolean AND. แก้ไขแล้ว
4
ต.ค. 21
79979
0
เม.ย. 21
5419
1
ธ.ค. 19
3688