Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to make button in tree view header always show up without selecting a record?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
wizardtreeviewbutton
5 Risposte
16477 Visualizzazioni
Avatar
Denny Nur

Hi, in my case i want to create a button inside tree view header to call an existing wizard. my source code is working, but i need to select some record to show my custom button. did missing something or this is a wrong way to create custom button on tree view header?

tree_view.xml

<record id="view_bank_account_tree"model="ir.ui.view">
    <field name="name">bank.account.treefield>
    <field name="model">account.journalfield>
<field name="type">treefield>
<field name="arch"type="xml">
        <tree create='0'string="Bank Account">
         <header>
                <button name="show_wizard"type="object"string="Create"class="oe_highlight"/>
            header>
            <field name="name"/>
            <field name="bank_id"/>
            <field name="bank_bic"/>
        tree>
    field>
record>

model.py

from odoo import models, fields, api

class bank_account(models.Model):
    _inherit='account.journal'
    bank_bic=fields.Char(string='Bank Identifier Code', related='bank_id.bic')

    def show_wizard(self):
    return {
        'name' : 'Add a Bank Account',
        'type' : 'ir.actions.act_window',
        'res_model' : 'account.setup.bank.manual.config',
        'views' : [[False, 'form']],
        'target' : 'new'
}
2
Avatar
Abbandona
Avatar
Rama Altayeb
Risposta migliore
For odoo15 Follow this tutorial 

www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15

For odoo16 Follow the same tutorial 

But put your xml and js files in assets_backend bundle
and then change o_list_button_button to o_list_button_add

 

<t t-extend="ListView.buttons" t-name="some_unique_name">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <button type="button" class="btn btn-primary open_wizard_action">
                    Open Wizard
            </button>
        </t>
    </t> 


       
           
       
     

    

           

       

   


1
Avatar
Abbandona
Avatar
Niko
Risposta migliore

adding  display="always" works for Odoo v18

0
Avatar
Abbandona
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Risposta migliore

Hi,

Inorder to make a button in the tree view, first you need to create an xml extending the list view buttons.

<templates id="template" xml:space="preserve">


    <t t-extend="ListView.buttons">


        <t t-jquery="div.o_list_buttons" t-operation="append">


            <button type="object" class="btn  btn-class">


                /* button name */


            </button>


        </t>


    </t>


</templates>


And then, you need to add a js file and include the button in ListController and setup the action.

var ListController = require("web.ListController");
var includeEdit = {

renderButtons: function() {
this._super.apply(this, arguments);
this.$buttons.find('button.btn-class').click(this.proxy('btn_function'));
}
},
 
btn_function: function() {
var action = {
type: "ir.actions.act_window",
name: /* Name of Wizard*/,
res_model: /* Wizard Model */,
views: [[false,'form']],
target: 'new',
view_type : 'form',
view_mode : 'form',
context : {/* Context to be passed */},
}
return this.do_action(action);
},
}
ListController.include(includeEdit);
});

Regards

0
Avatar
Abbandona
Avatar
Denny Nur
Autore Risposta migliore

thank you, it works correctly but since odoo has default create button and when I try to append it. My tree view shows 2 button create, one from default odoo and the other is custom from mine. is it possible if adding condition on my button? i want my custom button will apear only on my tree and make odoo default button invisible

0
Avatar
Abbandona
Avatar
XOLUTO
Risposta migliore

simplest solution for this need is to use   display="always" in button

Example:

 <tree>          

​<header>            

​ ​<button name="action_do_something" string="Button text"              ​ ​

​ ​ ​type="object" display="always"          

​ ​ ​class="btn-primary">

​ ​</button>          

​</header>

-1
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Custom Button in Tree View
treeview button
Avatar
Avatar
1
mag 24
2726
How to call button in <act_window>
treeview button
Avatar
Avatar
1
feb 17
6381
[SOLVED] How to make button clickable before setting mandatory fields in wizard ? - odoo 9 Risolto
wizard button
Avatar
Avatar
1
nov 16
6861
open wizard from tree view
wizard treeview
Avatar
Avatar
1
gen 16
8016
How to add a single button in tree view ?
treeview button
Avatar
Avatar
1
mar 15
16870
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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