Odoo 中的客户端操作

Dex*_*exJ 6 web odoo odoo-view odoo-10

在 Odoo/openerp 文档中,它说“客户端操作”完全在客户端实现,就是这样。他们没有为 Odoo v10 提供任何有关它的示例详细文档。

有谁知道如何实施客户行动及其全部潜力吗?(我们可以通过客户行动来实现的可能性。)

Sud*_*pta 5

客户端操作基本上是在 xml 中定义的菜单项,相应的操作被映射到一个小部件。

以下是客户端操作的实现:

您的 XML 文件将包含以下代码:

<record id="some-report-client-action" model="ir.actions.client">
  <field name="name">Report Page</field>
  <field name="tag">report.report_page</field>
</record>

<menuitem id="some-report-menuitem" name="Some" parent="pdf_report"
              action="some-report-client-action"/>
Run Code Online (Sandbox Code Playgroud)

创建一个用于创建小部件的 js 文件。它将包含以下代码:

openerp.guard_payments = function(instance, local) {
var _t = instance.web._t,
    _lt = instance.web._lt;
var QWeb = instance.web.qweb;

local.HomePage = instance.Widget.extend({
    template: 'MyQWebTemplate',
    init: function(parent, options){
      this._super.apply(this, arguments);
      this.name=parent.name;
    },
    start: function() {
      this._super.apply(this, arguments);
      console.log('Widget Start')
    },
});

//Following code will attach the above widget to the defined client action

instance.web.client_actions.add('report.report_page', 'instance.guard_payments.HomePage');
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我们可以创建一个完全自定义的 QWeb 模板并向其添加任何功能。

基本上这是 Odoo 提供的最好的部分