OpennERP确认消息

时间:2014-09-29 11:23:38

标签: python openerp confirmation

我曾尝试在create方法中使用this warning box module,但由于create方法的返回必须是数据库中创建的记录ID(而不是其他任何东西),因此会产生错误。

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

我不想使用Javascript。

我还使用了Python Easy Gui库。它在本地运行良好,但在远程服务器上会产生此错误:

  

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

尝试克服此问题时,我已使用ssh命令行(-X)中的ssh -X UserName@IP属性登录远程服务器,并且该库在测试时运行良好,因此解决此问题的解决方案正确设置ssh配置文件的参数但它还没有工作。

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

2 个答案:

答案 0 :(得分:1)

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

1)在按钮中,您可以向定义添加一个名为confirm的特殊字段,并且单独执行您想要的操作。例如:

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

我希望这会对你有所帮助! 谢谢和问候

答案 1 :(得分:0)

正确的方法是使用向导。

这意味着一些开销,因为你必须事先为向导定义一个Model和一个Form View,但在标准的Odoo中没有捷径。