odoo-11

Remove Delete Icon From One2many Field on condtion Base(Odoo 11)


I want to remove the delete icon in Odoo for some line in the one2many field where the Boolean field is True


Solution

  • You need to disable default delete button, then create your own delete button and apply your condition on it:

    <tree string="My Tree" delete="false">
        <field name="my_field1"/>
        <field name="my_field2"/>
        <field name="my_boolean_field"/>
        <button name="unlink"
                string="Unlink"
                type="object"
                class="btn-secondary"
                attrs="{'invisible': [('my_boolean_field', '=', False)]}"
                icon="fa-trash-o"/>
    </tree>