我创建了一个自定义模块,该模块要在树视图中停止“创建”按钮,以打开表单视图。我不想打开表单视图,而是向User显示一个弹出窗口。可以吗?
我尝试了以下代码:
@api.model
def onchange(self,values):
print "on onchange called"
raise ValidationError('Creation of new record is not allowed.')
return False
它会显示一个弹出窗口,但在单击“创建”按钮后仍会打开表单视图。
答案 0 :(得分:1)
我找到了解决方法:
@api.model
def default_get(self,values):
if 'lte_status' in values:
raise ValidationError('Creation of new record is not allowed.')
return False
return super(simcard,self).default_get(values)