I am making a tree view for one2many field
I will create the records for user to edit at the beginning so I don't want to let them create or delete records but only edit them
what should I put in the xml?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I am making a tree view for one2many field
I will create the records for user to edit at the beginning so I don't want to let them create or delete records but only edit them
what should I put in the xml?
Hello Willie ho,
To achieve this you need to add 2 attributes in your One2Many field's tree view.
1. create = "false"
2. delete = "false"
In below example, I have stopped create and delete in sale order line. ( This is tree view declared for order line in Sale Order's form view )
<tree string="Sales Order Lines" editable="bottom" create="false" delete="false">
<field name="sequence" widget="handle"/>
<field name="state" invisible="1"/>
<field name="th_weight" invisible="1"/>
<field name="product_id" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" groups="base.group_user" on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, False, product_uos_qty, False, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
<field name="name"/>
<field name="product_uom_qty" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom}" on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/>
<field name="product_uom" on_change="product_uom_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, context)" groups="product.group_uom" options="{"no_open": True}"/>
<field name="product_uos_qty" groups="product.group_uos" invisible="1"/>
<field name="product_uos" string="UoS" groups="product.group_uos" invisible="1"/>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','<>','purchase')]"/>
<field name="discount" groups="sale.group_discount_per_so_line"/>
<field name="price_subtotal"/>
</tree>
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up