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

A while ago Sudhir greatly helped with my issue on adding fields to my view without changing the original view (sale.order.form).


With his help I extended the sale order form view with:

<xpath expr="//field[@name='partner_id']" position="after" >
                    <field name="my_field_1" invisible="not context.get('show_custom', False)"/>
                    <field name="my_field_2" invisible="not context.get('show_custom', False)"/>
                </xpath>


The context was defined within the action: context="{'show_custom': True}"

This will change my view without impacting the original ones (i.e. Quotations and/or Sale Orders).

I plan to add much more to my view and I was wondering if I can somehow "globally" change the context.get' i.e. within the <xpath>.

For instance, I tried:


<xpath expr="//field[@name='partner_id']" position="after" invisible="not context.get('show_custom', False)">
                    <field name="my_field_1"/>
                    <field name="my_field_2"/>
                </xpath>


Even though this wont create any errors, it wont work. I was wondering if there is a way to apply the not context.get to all the custom fields inside the xpath, I mean without repeating the code for every individual field.

 





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

Hello,

    You can mention invisible= "not context.get('show_custom', False)" (attribute) for a <group> or a <page> by creating the group or page inside your xpath, so that you need not use for every field as you mentioned.      


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Select multiple elements with XPath แก้ไขแล้ว
5
ส.ค. 24
46625
1
ก.ค. 24
2006
2
เม.ย. 24
2548
3
มิ.ย. 23
5772
2
มิ.ย. 23
4712