This question has been flagged
1 Reply
1713 Views

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.

 





Avatar
Discard
Best Answer

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.      


Avatar
Discard