Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
10276 มุมมอง

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ธ.ค. 23
2490
1
มี.ค. 15
12245
Add a field to CRM Kanban View - Inherit แก้ไขแล้ว
1
พ.ค. 21
6689
1
ส.ค. 16
5105
3
ก.ย. 15
6276