Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2988 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
5
srp 24
46618
1
čvc 24
2006
2
dub 24
2546
3
čvn 23
5770
2
čvn 23
4709