Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
10339 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

Thanks,
Tri

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 12 23
2510
1
thg 3 15
12253
1
thg 5 21
6713
1
thg 8 16
5116
3
thg 9 15
6293