Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How to add Button on treeview header and to call a wizard from Odoo 12?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
treeviewbuttonsodoo12
1 Răspunde
14123 Vizualizări
Imagine profil
gain charlie

Hi Odoo Experts,

I want to add a new button place on treeview header in odoo 12 and call a wizard to do something.

I have research and found some blogs but its on older version.

I did try it but it fail to make it work.

Thank you for your time and help in advance.

2
Imagine profil
Abandonează
Imagine profil
SLIFE AFRICA
Cel mai bun răspuns

STEP 1: INHERIT THE TREE VIEW QWEB TEMPLATE

Define a xml file : static/src/xml/template.xml
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="after">
<button t-if='widget' type="button" class="btn btn-secondary o_button_to_call_wizard">
    Import
   </button>
</t>
</t>


STEP 2: INHERIT THE LIST CONTROLLER JS

Define a js file : static/src/js/list_controller.js
odoo.define('your_module_folder.JsToCallWizard', function (require) {
"use strict";

var ListController = require('web.ListController');

var JsTocallWizard = ListController.include({
renderButtons: function($node){
this._super.apply(this, arguments);
if (this.$buttons) {
this.$buttons.on('click', '.o_button_to_call_wizard', this.action_to_call_wizard.bind(this));
this.$buttons.appendTo($node);
}
},
action_to_call_wzard: function(event) {
event.preventDefault();
var self = this;
self.do_action({
name: "Open a wizard",
type: 'ir.actions.act_window',
res_model: 'my.wizard.model.name',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'new',
});

},
});
});

STEP 3 : ADD YOUR JS FILE IN ASSETS BACKEND

XML File : views/assets_backend.xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend" name="Backend Assets">
<xpath expr="//script[last()]" position="after">
<script src="/your_module_folder/static/src/js/list_controller.js"></script>
</xpath>
</template>
</odoo>

STEP 3: DECLARE YOUR FILES IN MANIFEST

'data': ['views/assets_backend.xml'],
'qweb': ['static/src/xml/template.xml'],


2
Imagine profil
Abandonează
Hilar Andikkadavath

Neat Explanation.

gain charlie
Autor

Hi, Frejus,

I have created the file above and replace "your_module_folder" in both js file.

I have added the manifest file param in both 'data' and 'qweb ' .

Question, is 'qweb' applicable to Odoo 12?( cant see it in manifest odoo 12 documentation.)

When i run it i got the following error( am not familiar with js):

Uncaught TypeError: Cannot read property 'bind' of undefined

http://localhost:8069/web/content/491-e52e898/web.assets_backend.js:3194

Traceback:

TypeError: Cannot read property 'bind' of undefined

at Class.renderButtons (http://localhost:8069/web/content/491-e52e898/web.assets_backend.js:3194:330)

at Class.renderButtons (http://localhost:8069/web/content/457-f2407d2/web.assets_common.js:3541:371)

at Class._renderControlPanelElements (http://localhost:8069/web/content/491-e52e898/web.assets_backend.js:1290:175)

at Class.start (http://localhost:8069/web/content/491-e52e898/web.assets_backend.js:1282:1427)

at Class.prototype.(anonymous function) [as start] (http://localhost:8069/web/content/457-f2407d2/web.assets_common.js:3538:488)

at Class.start (http://localhost:8069/web/content/491-e52e898/web.assets_backend.js:1541:1042)

at Class.prototype.(anonymous function) [as start] (http://localhost:8069/web/content/457-f2407d2/web.assets_common.js:3538:488)

at http://localhost:8069/web/content/457-f2407d2/web.assets_common.js:3683:52

at http://localhost:8069/web/content/457-f2407d2/web.assets_common.js:802:681

at fire (http://localhost:8069/web/content/457-f2407d2/web.assets_common.js:796:299)

SLIFE AFRICA

You can try this code :

odoo.define('your_module_folder.JsToCallWizard', function (require) {

"use strict";

var ListController = require('web.ListController');

var JsTocallWizard = ListController.include({

renderButtons: function($node){

this._super.apply(this, arguments);

if (this.$buttons) {

this.$buttons.on('click', '.o_button_to_call_wizard', function () {

var self = this;

self.do_action({

name: "Open a wizard",

type: 'ir.actions.act_window',

res_model: 'my.wizard.model.name',

view_mode: 'form',

view_type: 'form',

views: [[false, 'form']],

target: 'new',

});

});

this.$buttons.appendTo($node);

}

},

});

});

gain charlie
Autor

I have copied everything on hr_clock_import/static/src/js/list_controller.js the above code,

except replaced "your_module_folder" to hr_clock_import.

Result : Error gone.

But it does not display the button on the tree view header. i.e. after CREATE or IMPORT button

Am trying to add a new button from ATTENDANCE treeview called DOWNLOAD

OdooBot
Hi Frejus,

I have copied everything on hr_clock_import/static/src/js/list_controller.js the above code,

except replaced "your_module_folder" to hr_clock_import.

Result : Error gone.

But it does not display the button on the tree view header. i.e. after CREATE or IMPORT button

Am trying to add a new button from ATTENDANCE treeview called DOWNLOAD


I have attached my code below for your analysis.
Thank your for your time.
God Bless!

Gain Charlie
Odoo User
On Wednesday, 16 October 2019, 4:26:31 am GMT+8, Fréjus Arnaud AKA <frejusarnaud@gmail.com> wrote:


View Forum Post Odoo S.A.

You can try this code :

odoo.define('your_module_folder.JsToCallWizard', function (require) {

"use strict";

var ListController = require('web.ListController');

var JsTocallWizard = ListController.include({

renderButtons: function($node){

this._super.apply(this, arguments);

if (this.$buttons) {

this.$buttons.on('click', '.o_button_to_call_wizard', function () {

var self = this;

self.do_action({

name: "Open a wizard",

type: 'ir.actions.act_window',

res_model: 'my.wizard.model.name',

view_mode: 'form',

view_type: 'form',

views: [[false, 'form']],

target: 'new',

});

});

this.$buttons.appendTo($node);

}

},

});

});

Sent by Odoo S.A. using Odoo.

Tri Nanda

I got this error:
Uncaught TypeError: self.do_action is not a function

when using the last code @gain charlie
is there any solustions @gain charlie and @Fréjus Arnaud AKA and anyone on this forum?

Thanks,
Tri

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to add buttons in tree view header and run a function in Odoo 12?
treeview buttons odoo12
Imagine profil
Imagine profil
1
oct. 19
7716
In Odoo 12, How to create a new button alongside CREATE button of a treeview and call a wizard
wizard treeview buttons odoo12
Imagine profil
Imagine profil
1
oct. 19
3812
Odoo 12, how to add a button to treeview header and call the existing wizard? Rezolvat
wizard treeview buttons odoo12
Imagine profil
Imagine profil
Imagine profil
2
oct. 19
9315
add one button in treeview to sync many records from another app API Rezolvat
treeview buttons
Imagine profil
Imagine profil
2
iun. 22
3463
input type text field and my button instead default buttons in treeview
treeview buttons
Imagine profil
0
iul. 17
4938
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now