跳至内容
菜单
此问题已终结
2 回复
9977 查看

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.

形象
丢弃
最佳答案

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

形象
丢弃

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

Thanks,
Tri

最佳答案

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

形象
丢弃
编写者

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

相关帖文 回复 查看 活动
3
12月 23
2305
1
3月 15
12130
1
5月 21
6561
1
8月 16
5035
3
9月 15
6152