有人可以建议如何在一个字段为 True 时删除 one2many 行中的删除按钮
can someone suggest how to remove delete button in one2many lines whenone field is True
有人可以建议如何在一个字段为 True 时删除 one2many 行中的删除按钮
我试过用
定义取消链接(自我):
并覆盖此方法
注意:我在 odoo 10 中工作
您可以设置 以禁止删除所有记录。否则没有办法对此提出条件。
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()
希望对您有所帮助!
有人可以建议如何在一个字段为 True 时删除 one2many 行中的删除按钮
我试过用 定义取消链接(自我): 并覆盖此方法
注意:我在 odoo 10 中工作
您可以设置
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()
希望对您有所帮助!