我尝试使用 this warning box module在create方法中,但它会产生错误,因为create方法的返回必须是数据库中创建的记录ID(而不是其他任何东西)。
我只想在用户创建或编辑 View 时单击“保存”时显示确认消息(是/否)。
我不想使用 JavaScript。
我还使用了 Python Easy Gui 库。它在本地运行得很好,但在远程服务器上它会产生以下错误:
_tkinter.TclError: no display name and no $DISPLAY environment variable
当尝试解决此问题时,我在 ssh 命令行中使用 -X
属性 (ssh -X UserName@IP
) 登录远程服务器,并且库在测试时运行良好,因此解决此问题的解决方案是正确设置 ssh 配置文件的参数,但它还不起作用。
如何在create方法中创建确认消息?
最佳答案
有两种方法可以做到这一点,
1) 在“按钮”中,您可以在定义中添加一个名为“确认”的特殊字段,单独使用该字段即可执行您想要的操作。例如:
<button name="Name of the button"
string="Showable label"
type="object"
confirm="Are you sure you want to do this?"
/>
这将弹出一个确认窗口,显示文本“您确定要执行此操作吗?”。
2)您可以创建一个向导,其中有两个按钮,一个是特殊取消类型,另一个执行一个函数,该函数也将调用工作流中的确认函数。
示例:
<record id="view_cancel_repair" model="ir.ui.view">
<field name="name">Cancel Repair</field>
<field name="model">mrp.repair.cancel</field>
<field name="arch" type="xml">
<form string="Cancel Repair Order" version="7.0">
<group>
<label string="This operation will cancel the Repair process, but will not cancel it's Invoice. Do you want to continue?"/>
</group>
<footer>
<button name="cancel_repair" string="Yes" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
希望这对您有帮助! 感谢和问候
关于python - OpennERP确认消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26098748/