This question has been flagged
1 Reply
9171 Views

Hello All,

I've added a button on list view near create and import button. Now I want to apply action on that button but function not calling on that button. The button is visible on the list view and also file called, I tested with alert. First alert working fine but ListView.include alert not working.

My js and XML code is here:

odoo.define('custom_project.web_export_view', function (require){
"use strict";

var core = require('web.core');
var ListView = require('web.ListView');
var QWeb = core.qweb;
alert('Help1');
console.log('testtt',ListView.include)
ListView.include({

render_buttons: function($node) {
alert('Help2');
var self = this;
this._super($node);
this.$buttons.find('.o_list_tender_button_create').click(this.proxy('tree_view_action'));
},

tree_view_action: function () {
alert('Help3');
this.do_action({
type: "ir.actions.act_window",
name: "product",
res_model: "product.template",
views: [[false,'form']],
target: 'current',
view_type : 'form',
view_mode : 'form',
flags: {'form': {'action_buttons': true, 'options': {'mode': 'edit'}}}
});
return { 'type': 'ir.actions.client','tag': 'reload', } }

});
}); 
<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>

Also attaching a screenshot for understanding.


Can Anyone suggest a solution for this problem?

Thanks in advance

Avatar
Discard
Author Best Answer

Hello ALL,

I Got a solution for my problem:

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(){
}
};
ListController.include(includeDict);
});

Thanks, everyone

Avatar
Discard

This is legit, I have been looking for working answer for very long time.