【问题标题】:Call or add function in act_window xml in odoo在odoo的act_window xml中调用或添加函数
【发布时间】:2018-12-11 23:14:27
【问题描述】:

我试图在树上的报告按钮上添加一个新标签。选择树数据之一后将显示该按钮。我做到了。我构建了一个在单击按钮后执行的函数。问题是,我不怎么调用act_windows里面的函数。

<act_window
id="action_report"
name="Print Report"
res_model="model.report"
key2="client_print_multi"
src_model="model.report"/>

如何在其中调用函数(def)。谢谢。

【问题讨论】:

  • 你尝试过服务器操作

标签: python xml odoo erp odoo-11


【解决方案1】:

查看ìr.actions.server 并了解它们是如何工作的。 Odoo 本身的一个很好的例子:

    <record id="hr_expense_submit_action_server" model="ir.actions.server">
        <field name="name">Expense: Submit To Manager</field>
        <field name="type">ir.actions.server</field>
        <field name="model_id" ref="model_hr_expense"/>
        <field name="binding_model_id" ref="model_hr_expense"/>
        <field name="state">code</field>
        <field name="code">
            if records:
                action = records.submit_expenses()
        </field>
    </record>

这是一项费用操作,用户可以一次向其经理提交多项费用。服务器操作的类型不止code,但这也应该是您的选择。

您在窗口操作中有res_model 和src_model(您的示例)。在服务器操作中,res_model 是 model_id,src_model 是 binding_model_id。

【讨论】:

  • 非常感谢。它正在工作。你是我的救星!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多