有没有办法在状态上限制 deletion/editing (Odoo-12)
Is there a way to restrict deletion/editing on the state (Odoo-12)
我正在使用 eclipse (odoo-12) 开发一个新项目,但存在一个问题,我需要限制删除和编辑并使其仅在特定状态下允许
示例:
如果状态为(已交付,已检索)
,则不允许删除
我已经尝试 sql 限制,但我不知道如何
你可以尝试覆盖unlink方法
from odoo.exceptions import UserError
from odoo import _
@api.multi
def unlink(self):
if self.state in ['Delivered','Retrieved']:
raise UserError(_('message'))
return super(YourClass, self).unlink()
我正在使用 eclipse (odoo-12) 开发一个新项目,但存在一个问题,我需要限制删除和编辑并使其仅在特定状态下允许
示例: 如果状态为(已交付,已检索)
,则不允许删除我已经尝试 sql 限制,但我不知道如何
你可以尝试覆盖unlink方法
from odoo.exceptions import UserError
from odoo import _
@api.multi
def unlink(self):
if self.state in ['Delivered','Retrieved']:
raise UserError(_('message'))
return super(YourClass, self).unlink()