odooodoo-17

Odoo 17 remove product_uom from sale_order_lines


On the sale order line view table, there is a column product_uom, and I can't figure out how to remove it. I created a custom addon to customize my view; everything works fine except this field, which sticks to my view.

Here is my code:

<record id="view_sale_order_form_inherit_napsis_sales" model="ir.ui.view">
    <field name="name">sale.order.form.inherit.napsis.sale</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='product_uom'] " position="replace">
            <field name="product_uom" invisible="1" groups="!uom.group_uom" column_invisible="True" class="oe_no_button d-none"/>
            <field name="product_uom" force_save="1" groups="uom.group_uom" class="oe_no_button d-none" readonly="product_uom_readonly" required="not display_type" column_invisible="True" invisible="1" />
        </xpath>
    </field>
</record>

The column_invisible attribute doesn't apply here...

What's wrong?


Solution

  • column_invisible can only be used within attrs attribute like this

    <xpath expr="//[your_xpath]" position="attributes">
        <attribute name="attrs">{'column_invisible': [('parent.field_name', '=', True)]}</attribute>
    </attributes>
    

    field_name should be defined in the parent model. For example in your case, it should be a field in the sale.order model.