我想在树形视图中的创建按钮附近添加自定义按钮。对于特定的模型树视图,仅在odoo11中。 这是我的示例代码:
var QWeb = core.qweb;
var _t = core._t;
var Compare = ListView.extend({
template: 'CompareListView.buttons',
render_buttons: function($node) {
if (!this.$buttons) {
this.$buttons = $(QWeb.render("CompareListView.buttons", {
'widget': this
}));
this.$buttons.find('.oe_generate_po').click(this.proxy('generate_purchase_order'));
$node = $node || this.options.$buttons;
if ($node) {
this.$buttons.appendTo($node);
} else {
this.$('.oe_list_buttons').replaceWith(this.$buttons);
}
}
},
start: function() {
this._super.apply(this, arguments);
var self = this;
},
});
registry.add('Compare Button', Compare);
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-name="CompareListView.buttons">
<div class="oe_list_buttons">
<button type="button" class="btn btn-sm btn-primary oe_generate_po">
Generate PO
</button>
</div>
</t>
</template>
谢谢。