can someone suggest how to remove delete button in one2many lines whenone field is True

1.3k Views Asked by At

can someone suggest how to remove delete button in one2many lines whenone field is True

i have tried using def unlink(self): and overridding this method

Note: i am working in odoo 10

1

There are 1 best solutions below

2
On BEST ANSWER

You can set <tree delete="0"> in view to disable deletion for all records. otherwise there is not way to put condition on that.

The way you tried overriding unlink() is only way to do it. you can check your Boolean field value in method and raise Error Accordingly.

@api.multi
def unlink(self):
    for rec in self:
        if rec.your_boolean_field :
            raise UserError(_('In order to delete a record, you must first unset your_boolean_field.'))
    return super(YourModel, self).unlink()

hope this helps!