0

JS代码

var employee_data = [];

var nodeTemplate = function(data) {
      return `
        <span class="office">${data.office}</span>
        <div class="title">${data.name}</div>
        <div class="content">${data.title}</div>
      `;
    };

odoo.define("org_chart_employee.org_chart_employee", function (require) {
  "use strict";

  var AbstractAction = require('web.AbstractAction');
  var core = require('web.core');
  var session = require('web.session');
  var ajax = require('web.ajax');
  var Widget = require('web.Widget');
  var ControlPanelMixin = require('web.ControlPanelMixin');
  var QWeb = core.qweb;
  var _t = core._t;
  var _lt = core._lt;

  var OrgChartDepartment = AbstractAction.extend({
    init: function(parent, context) {
      this._super(parent, context);
        var self = this;
        if (this.action.tag == 'org_chart_department') {
            self._rpc({
                model: 'org.chart.employee',
                method: 'get_employee_data',
            }).then(function(result){
                employee_data = result;
            }).done(function(){
                self.render();
                self.href = window.location.href;
            });
        }
    },
    willStart: function() {
      return $.when(ajax.loadLibs(this), this._super());
    },
    start: function() {
      var self = this;
      return this._super();
    },
    render: function() {
        var self = this;
        var org_chart = QWeb.render('org_chart_employeeOrg_chart_template', {
            widget: self,
        });
        $( ".o_control_panel" ).addClass( "o_hidden" );
        $(org_chart).prependTo(self.$el);
        return org_chart;
    },
    reload: function () {
      window.location.href = this.href;
    },
  });
  core.action_registry.add('org_chart_department', OrgChartDepartment);
  return OrgChartDepartment;
});

当我尝试在 Odoo 13 中打开菜单时,控制台给出“找不到客户端操作 org_chart_department 对象 { id:161,名称:“员工图表”,类型:“ir.actions.client”,标签:“org_chart_department”,目标: "current", res_model: false, context: {...}, params: false, params_store: false, xml_id: "org_chart_employee.action_org_chart_employee", ... }" 它出现了 " res_model: false" 如何解决?

4

2 回答 2

0

利比亚扎鲁格,

你有没有让客户端动作像这样,

<record id="action_id" model="ir.actions.client">
    <field name="name">Name</field>
    <field name="res_model">Model</field>
    <field name="tag">Your Registry Add[org_chart_department]</field>
</record>

仅供参考,只需检查以下链接,

account_view对账操作

谢谢

于 2020-03-30T07:44:52.550 回答
0

感谢 Dipen Shah,它有帮助。我出现了 js 函数不是以 odoo.define() 开头的,但它解决了。

于 2020-04-07T19:29:49.800 回答