Skip to Content
Menu
This question has been flagged
2 Replies
2470 Views

I want the field to be invisible but I have this error

how to correct this error ???

this is my code 

<?xml version="1.0" encoding="UTF-8"?>

<odoo>

<record id="sale_order_inherit" model="ir.ui.view">

    <field name="name">sale.order</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

    <field name="arch" type="xml">

        <xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_uom_qty']" position="replace">

        </xpath>

    </field>

</record>



</odoo>


and this is error 

odoo.exceptions.ValidationError: ('Erreur lors de la validation de la contrainte\n\nField \'product_uom_qty\' used in attributes must be present in view but is missing:\n - \'product_uom_qty\' in context="{\'partner_id\':parent.partner_id, \'quantity\':product_uom_qty, \'pricelist\':parent.pricelist_id, \'uom\':product_uom, \'company_id\': parent.company_id}"\n\nContexte de l\'erreur :\nVue `sale.order`\n[view_id: 1191, xml_id: n/a, model: sale.order, parent_id: 1130]', None)

Avatar
Discard
Best Answer

Hi,

Instead of replacing the code make it invisible using the attributes,


<record id="sale_order_inherit" model="ir.ui.view">
<field name="name">sale.order</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_uom_qty']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>


As the field is a required field you will get an error if you use replace


Thanks

Avatar
Discard