Javascript odoo 11列表视图按钮上的调用操作(功能)

Javascript odoo 11列表视图按钮上的调用操作(功能),javascript,listview,odoo,odoo-11,Javascript,Listview,Odoo,Odoo 11,我在列表视图的“创建和导入”按钮附近添加了一个按钮。现在我想对该按钮应用操作,但函数不调用该按钮。该按钮在列表视图中可见,也被称为文件,我用alert进行了测试。第一个警报工作正常,但ListView.include警报不工作 我的js和XML代码如下: <?xml version="1.0" encoding="UTF-8"?> <templates> <t t-extend="ListView.buttons" id="template" xml:spa

我在列表视图的“创建和导入”按钮附近添加了一个按钮。现在我想对该按钮应用操作,但函数不调用该按钮。该按钮在列表视图中可见,也被称为文件,我用alert进行了测试。第一个警报工作正常,但ListView.include警报不工作

我的js和XML代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<templates>
    <t t-extend="ListView.buttons" id="template" xml:space="preserve">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <button t-if="widget.model != 'account.analytic.line'" class="btn btn-primary btn-sm sync_button"
                    type="button" >HELP
            </button>
        </t>
    </t>
</templates>
同时附上一个屏幕截图以供理解

有人能提出解决这个问题的办法吗


提前谢谢

你能这样写吗:

XML:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="help_btn_template" xml:space="preserve">
<t t-extend="ListView.buttons" id="template" xml:space="preserve">
    <t t-jquery="button.o_list_button_add" t-operation="after">
        <button t-if="widget.model != 'account.analytic.line'" class="btn btn-primary btn-sm sync_button o_button_help"
                type="button" >HELP
        </button>
    </t>
</t>
odoo.define('custom_project.web_export_view', function (require) {

"use strict";       
var core = require('web.core');
var ListView = require('web.ListView'); 
var ListController = require("web.ListController");

var includeDict = {
    renderButtons: function () {
        this._super.apply(this, arguments);
        if (this.modelName === "account.analytic.line") {
            var your_btn = this.$buttons.find('button.o_button_help')                
            your_btn.on('click', this.proxy('o_button_help'))
        }
    },
    o_button_help: function(){
        var self = this;
        var state = self.model.get(self.handle, {raw: true});
        return self.do_action({
            name: 'product',
            type: 'ir.actions.act_window',
            res_model: 'product.template', #This model must Transient Model
            target: 'new',
            views: [[false, 'form']], 
            view_type : 'form',
            view_mode : 'form',
            flags: {'form': {'action_buttons': true, 'options': {'mode': 'edit'}}
        });
    }
};
ListController.include(includeDict);                
}); 

我希望这对你有帮助。多谢各位

谢谢,它起作用了。。。o_按钮帮助:function()中只有一个小错误,在注释后,工作正常。
odoo.define('custom_project.web_export_view', function (require) {

"use strict";       
var core = require('web.core');
var ListView = require('web.ListView'); 
var ListController = require("web.ListController");

var includeDict = {
    renderButtons: function () {
        this._super.apply(this, arguments);
        if (this.modelName === "account.analytic.line") {
            var your_btn = this.$buttons.find('button.o_button_help')                
            your_btn.on('click', this.proxy('o_button_help'))
        }
    },
    o_button_help: function(){
        var self = this;
        var state = self.model.get(self.handle, {raw: true});
        return self.do_action({
            name: 'product',
            type: 'ir.actions.act_window',
            res_model: 'product.template', #This model must Transient Model
            target: 'new',
            views: [[false, 'form']], 
            view_type : 'form',
            view_mode : 'form',
            flags: {'form': {'action_buttons': true, 'options': {'mode': 'edit'}}
        });
    }
};
ListController.include(includeDict);                
});