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


I'm trying to make the fields "Margin" and "Margin Percent" invisible on the sale.order.line model, but I'm having trouble finding the correct view to inherit. Here is the code I'm currently using:

record id="view_order_line_form_inherit" model="ir.ui.view"

                field name="name"  sale.order.line.form.inherit  field

                field name="model"  sale.order.line  field

                field name="inherit_id" ref="sale_margin.sale_margin_sale_order_line_form"

                field name="arch" type="xml"

                        xpath expr="//field[@name='margin']" position="attributes"

                                attribute name="invisible"  1  /attribute

                        /xpath

                        xpath expr="//field[@name='margin_percent']" position="attributes"

                                attribute name="invisible"  1  /attribute

                        xpath

                field

        record


Help me please.

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

margin and margin_percent fields are inside the sale order line (o2m field of sale order). So you will have to traverse to these fields in the xpath as shown in the below code.

    record model="ir.ui.view" id="sale_margin_sale_order_line_form"
        field name="name">sale.order.line.tree.margin.view.form/field
        field name="model">sale.order/field
        field name="inherit_id" ref="sale_margin.sale_margin_sale_order_line_form"/
        field name="arch" type="xml">
           xpath expr="//field[@name='order_line']/tree//field[@name='margin']" position="attributes"
               attribute name="invisible">1 /attribute
           /xpath
           xpath expr="//field[@name='order_line']/tree//field[@name='margin_percent']" position="attributes"
               attribute name="invisible">1 /attribute
           /xpath
        /field
    /record

อวตาร
ละทิ้ง
ผู้เขียน

Thanks!

The issue was with //field[@name='order_line']/tree. I didn't know about this function. Thank you so much for your help!

คำตอบที่ดีที่สุด

Hi,

The margin and margin_percent fields are optional. You can hide them by disabling the fields using the toggle button in the sale order line.

Alternatively, you can also do it through the code:

<record model="ir.ui.view" id="sale_margin_sale_order_line_form">
<field name="name">sale.order.line.tree.margin.view.form</field>
<field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree//field[@name='margin']" position="attributes">
<attribute name="column_invisible">1</attribute>
            </xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='margin_percent']" position="attributes">
<attribute name="column_invisible">1</attribute>
            </xpath>
        </field>
    </record>

Make sure to add 'sale_margin' to the depends of your manifest file.


Hope it helps

อวตาร
ละทิ้ง
ผู้เขียน

Thanks!

The issue was with //field[@name='order_line']/tree. I didn't know about this function. Thank you so much for your help!

I really thank you!!!

คำตอบที่ดีที่สุด

Hi,

You should inherit sale.order instead of sale.order.line.

Please check below screenshot :

 

  

           

   



       

       

   

อวตาร
ละทิ้ง
ผู้เขียน

Thanks!

The issue was with //field[@name='order_line']/tree. I didn't know about this function. Thank you so much for your help!

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 24
3921
1
ก.พ. 21
2617
2
ต.ค. 20
5412
3
ก.ค. 19
6349
2
ม.ค. 23
3627