tree上导入表格
添加按钮
在static/src中编写xml模板
<templates id="bicon_base_goods_button" xml:space="preserve"> <t t-extend="ListView.buttons"> <t t-jquery="div.o_list_buttons" t-operation="append"> <t t-if="widget.displayName=='商品'"> <button class="btn btn-primary bicon_base_goods_button" type="button" groups="sys_manager.YHY_group">导出excel</button> </t> </t> </t> </templates>
在static/src中编写js文件
odoo.define(‘bicon_store.bicon_base_goods_button’, function (require) {
“use strict”;
//这些是调⽤需要的模块
var ListView = require(‘web.ListView’);
var viewRegistry = require(‘web.view_registry’);
var ListController = require(‘web.ListController’);
var dialogs = require(“web.Dialog”);
//这块代码是继承ListController在原来的基础上进⾏扩展
var BiConListController = ListController.extend({
renderButtons: function () {
this._super.apply(this, arguments);
if (this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …var btn = this.buttons.find(’.bicon_base_goods_button’);
//给按钮绑定click事件和⽅法create_data_by_dept
btn.on(‘click’, this.proxy(‘create_data_by_dept’));
}
},
create_data_by_dept: function () {
var self = this;
//这⾥是获取tree视图中选中的数据的记录集
var records = _.map(self.selectedRecords, function (id) {
return self.model.localData[id];
});
console.log(“数据id:” + _.pluck(records, ‘res_id’));
//获取到数据集中每条数据的对应数据库