@ssun 这个js里面的有些属性在odoo11里面就已经不适用了,明显的:
var myListView = require('web.ListView');
var tree_model = this.dataset.model;
下面是我测试odoo11,odoo12都可以使用的,你对照看看:
odoo.define('xxx.add_tree_view_button', function (require) {
"use strict";
var show_button_model = ['product.template'];//哪些模型显示导入按钮
var ListController = require('web.ListController');
ListController.include({
renderButtons: function ($node) {
var $buttons = this._super.apply(this, arguments);
var tree_model = this.modelName;
for(var i=0; i<show_button_model.length; i++) {
if (tree_model == show_button_model[i]){
var button2 = $("<button type='button' class='btn btn-sm btn-default'>Import Excel</button>")
.click(this.proxy('popup_import_wizard'));
this.$buttons.append(button2);
}
}
return $buttons;
},
popup_import_wizard: function () {
this.do_action({
type: 'ir.actions.act_window',
res_model: 'import.wizard',
views: [[false, 'form']],
view_mode: "form",
view_type: 'form',
view_id: 'import_wizard_form',
target: 'new',
});
},
});
});