Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
10049 Visninger

hi, i'm trying to add a button in the header of the product's kanban view that I inherited on my costum module, i'm looking for a solution but nothing useful or comprehensible.

Can someone help me? I'd really appreciate, thanks in advance.

Avatar
Kassér
Bedste svar

Hi  Cristian ,

Refer ,

https://www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15

Hope it helps,
Kiran K

Avatar
Kassér

Thank you for the shared link,
But can you send how to achieve that in Odoo16?

Thanks,
Tri

Bedste svar

Hi,

To add buttons in the list and kanban view header, you need to create a template inside the XML path - static/src/xml/tree_button.xml and add below code to that template and add this file path in 'web.assets_qweb' in manifest.

Button For List View

<templates>


   <t t-extend="ListView.buttons" t-name="button_test.buttons">


       <t t-jquery="button.o_list_button_add" t-operation="after">


           <button t-if="widget.modelName =='product.template' "type="button"


             class="btn btn-primary" t-on-click="_button_action">


               Button Name


           </button>


       </t>


   </t>


</templates>


Button For Kanban View

<templates>


   <t t-extend="KanbanView.buttons" t-name="button_test.button">


       <t t-jquery="button" t-operation="after">


          <button t-if="widget.modelName =='product.template'" type="button" 


           class="btn btn-primary" t-on-click="_button_action">


               Button Name


          </button>


       </t>


   </t>


</templates>


For further reference please check below mentioned link

How to Add a Create Button Near Tree & Kanban View in Odoo 15

Regards

Avatar
Kassér
Forfatter

Hi, thank you for the answer, I tried a lot, but nothing is working for me, here is how my files looke like:

custom_module/static/src/xml/kanban_button.xml

<?xml version="1.0" encoding="UTF-8"?>

<templates>
<t t-extend="KanbanView.buttons" t-name="import_hr.button">
<t t-jquery="button" t-operation="after">
<button t-if="widget.modelName =='res.partner'" type="object"
class="btn btn-primary" t-on-click="_OpenWizard">
Import Contacts
</button>
</t>
</t>
</templates>

custom_module/static/src/js/kanban_button.js

odoo.define('import_hr.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: 'import_hr.button',
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 SaleOrderKanbanView = KanbanView.extend({
config: _.extend({}, KanbanView.prototype.config, {
Controller: KanbanButton
}),
});
viewRegistry.add('button_in_kanban', SaleOrderKanbanView);
});

and the custom_module/__manifest__.py

{
'name': 'Import HR',
'version': '1.0',
'category': 'Extra tools',
'depends': ['contacts', 'base', 'mail', 'sale_management'],
'description' : """
description text...
""",
'data': [
'security/ir.model.access.csv',
'views/res_partners_views.xml',
],
'backend': [
'static/src/js/kanban_button.js',
],
'qweb': [
'static/src/xml/kanban_button.xml',
],
'demo': [

],
'installable': True,
'auto_install': False,
'license': 'LGPL-3',
}

but nothing is showing up,I looking around for everything could help but I can't understand what I'm getting wrong

Related Posts Besvarelser Visninger Aktivitet
3
dec. 23
2363
1
mar. 15
12158
1
maj 21
6580
1
aug. 16
5044
3
sep. 15
6174