Hi,
I'm trying to add a custom button next to the 'Create' button on the Contacts page in both Kanban and List views, which should open a wizard when clicked. I followed several blogs and tutorials to create a custom module, but after installing it, the Contacts app only opens the new contact form and hides the Kanban and List views. Has anyone done this successfully before? Any help would be appreciated!
My Implementation
list_button.xml
kaban_button.xml
list_button.js
odoo.define('button_near_create.list_button', function (require) {
"use strict";
var ListController = require('web.ListController');
var ListView = require('web.ListView');
var viewRegistry = require('web.view_registry');
var ListButton = ListController.extend({
buttons_template: 'button_near_create.list_buttons',
events: _.extend({}, ListController.prototype.events, {
'click .open_wizard_action_list': '_OpenWizardList',
}),
_OpenWizardList: function () {
var self = this;
this.do_action({
type: 'ir.actions.act_window',
res_model: 'test.wizard',
name :'Open Wizard',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
res_id: false,
});
}
});
var PartnerListView = ListView.extend({
config: _.extend({}, ListView.prototype.config, {
Controller: ListButton,
}),
});
viewRegistry.add('button_in_list', PartnerListView);
});
kanban_button.js
odoo.define('button_near_create.kanban_button', function(require) {
"use strict";
var KanbanController = require('web.KanbanController');
var KanbanView = require('web.KanbanView');
var viewRegistry = require('web.view_registry');
var KanbanButton = KanbanController.include({
buttons_template: 'button_near_create.kanban_buttons',
events: _.extend({}, KanbanController.prototype.events, {
'click .open_wizard_action_kanban': '_OpenWizardKanban',
}),
_OpenWizardKanban: function () {
var self = this;
this.do_action({
type: 'ir.actions.act_window',
res_model: 'test.wizard',
name :'Open Wizard',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
res_id: false,
});
}
});
var PartnerKanbanView = KanbanView.extend({
config: _.extend({}, KanbanView.prototype.config, {
Controller: KanbanButton
}),
});
viewRegistry.add('button_in_kanban', PartnerKanbanView);
});
assets.xml
views.xml
res.partner.view.list.inherit
res.partner
button_in_list
res.partner.view.kanban.inherit
res.partner
button_in_kanban