0
votes

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
Explain bit more your exception seems messy! and incomplete.DexJ
actually i have a one2many field containing one boolean field and other fields in it....what i want is whenever the boolean field is True i just want the delete button in that one2many lines should invisible.....mani shankar

1 Answers

1
votes

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!