1.继承ListView.buttons,在其按钮后面增加我们自定义的按钮,通过widget的一些属性去判断按钮的显示
<templates id="list_import_shipping_button_create" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="div.o_list_buttons" t-operation="append">
<!-- 找到名为 ""的模型,并在它的列表(tree)视图后面append一个按钮 -->
<t t-if="widget and widget.modelName == 'ffb.shipping.order' and widget._title == '国际运输单' and widget.controlPanelProps.action.context.is_show">
<button class="btn btn-success o_list_tender_import_shipping" type="button">导入</button>
</t>
</t>
</t>
</templates>
2.在js中增加对该按钮增加click事件,弹出向导
odoo.define('ffb_internation_shipping.list_import_shipping_button_create', function (require) {
"use strict";
var ListView = require('web.ListView');
var viewRegistry = require('web.view_registry');
var ListController = require('web.ListController');
ListController.include({
renderButtons: function ($node) {
this._super.apply(this, arguments);
if (this.$buttons) {
this.$buttons.on('click', '.o_list_tender_import_shipping', this.inport_voyage_shipping.bind(this));
}
},
inport_voyage_shipping: function () {
var self = this;
self.do_action({
type: 'ir.actions.act_window',
name: '国际运输单导入',
target: 'new',
res_model: 'import.shipping.wizard',
views: [[false, 'form']],
});
}
});
});
标签:web,Odoo14,shipping,视图,按钮,var,require,ListController From: https://www.cnblogs.com/yangzai21/p/17370360.html