2014-09-29 114 views
1

我试图在创建方法中使用this warning box module,但由于create方法的返回必须是数据库中创建的记录标识(而不是其他任何东西),所以会产生错误。OpennERP确认消息

我只想在用户在创建或编辑视图时单击保存时显示确认消息(是/否)。

我不想使用Javascript。

我也使用了Python Easy Gui库。它的工作原理非常好地方,但在远程服务器上它产生这样的错误:

_tkinter.TclError: no display name and no $DISPLAY environment variable

在试图解决这个问题,我已经登录的SSH命令行(ssh -X [email protected])使用-X属性的远程服务器和库在测试时运行良好,解决此问题的方法可以正确设置ssh配置文件的参数,但它仍然无法正常工作。

如何在创建方法中创建确认消息?

回答

0

正确的做法是使用向导。

这意味着一些开销,因为您必须事先为向导定义模型和窗体视图,但在标准Odoo中没有捷径。

1

有两种方法,通过它可以做到这一点,

1)按钮,可以添加一个名为确认该定义的特殊的领域,而且,独自一人,会做你想要什么。例如:

<button name="Name of the button" 
    string="Showable label" 
    type="object" 
    confirm="Are you sure you want to do this?" 
/> 

这将弹出一个确认窗口,显示文本“你确定要这样做?”。

2)您可以创建一个向导,使用两个Button,一个类型特殊取消,另一个执行一个函数,该函数也将调用工作流中的confirm函数。

例子:

<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> 

我希望这可以帮助你! 感谢和问候