本人刚接触ODOO,参考网上分享的案例尝试widget开发,注册了一个客户端动作,代码如下:
odoo.define('load_echarts', function (require) {
"use strict";
var core = require('web.core');
var Widget = require('web.Widget');
// 定义打开模板
var Echarts = Widget.extend({
// 模板名称 对应上面xml中t-name
template: 'echarts_capa_homepage',
init: function(parent, data){
return this._super.apply(this, arguments);
},
start: function(){
return true;
},
});
// 将上面定义的打开模板注册成客户端动作名对应client_action中的tag
core.action_registry.add('load_echarts.load_capa_homepage', Echarts);
})
但运行的时候报错了,错误信息如下:
TypeError: widget.getTitle is not a function
at Class._executeClientAction (http://localhost:8069/web/static/src/js/chrome/action_manager.js:446:27)
at Class._handleAction [as _super] (http://localhost:8069/web/static/src/js/chrome/action_manager.js:669:29)
at Class._handleAction (http://localhost:8069/web/static/src/js/chrome/action_manager_act_window.js:404:28)
at Class.<anonymous> (http://localhost:8069/web/static/src/js/core/class.js:123:38)
at Class._handleAction (http://localhost:8069/web/static/src/js/chrome/action_manager_report.js:164:28)
at Class._handleAction (http://localhost:8069/web/static/src/js/core/class.js:123:38)
at http://localhost:8069/web/static/src/js/chrome/action_manager.js:165:25
琢磨了很久也都没头绪,向大神们求助……:disappointed_but_relieved_face: :disappointed_but_relieved_face: :disappointed_but_relieved_face: