Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2998 Lượt xem

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.

 





Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.      


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 8 24
46625
1
thg 7 24
2006
2
thg 4 24
2548
3
thg 6 23
5772
2
thg 6 23
4712