콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
10103 화면

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
2394
1
3월 15
12173
1
5월 21
6605
1
8월 16
5057
3
9월 15
6191