0

Please i need to hide column "Description" in table "Order Lines" in form view external_id="sale.view_order_form", hide this column if details==True

Here is python code:

class ClassSaleOrder(models.Model):
    _inherit = 'sale.order'
    details = fields.Boolean()

Here is xml file :

<record id="module_sale_order_line_form" model="ir.ui.view">
    <field name="name">module.sale.order.line.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='partner_id']" position="after">
            <field name="details"/>
        </xpath>
    </field>
</record>
Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
Programmer LiLi
  • 147
  • 5
  • 27
  • add attribute in your field which you want to hide attrs={'invisible':[('default','=',True)]} – Akshay Mar 22 '19 at 13:17

2 Answers2

0

You need to use position='attributes' and define the value for invisible attribute.

<xpath expr="//field[@name='order_line']/form/group/field[@name='name']" position="attributes">
    <attribute name="invisible">[('details', '=', True)]</attribute>                
</xpath>
Kenly
  • 24,317
  • 7
  • 44
  • 60
0

Use the below code for making description field invisible when details is true

<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="attributes">
    <attribute name="attrs">{'invisible':[('details', '=', True)]}</attribute>                
</xpath>
Anitha Das B
  • 357
  • 2
  • 9