Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
wizardtreeviewbutton
5 Respuestas
16480 Vistas
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
Descartar
Avatar
Rama Altayeb
Mejor respuesta
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
Descartar
Avatar
Niko
Mejor respuesta

adding  display="always" works for Odoo v18

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

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
Descartar
Avatar
Denny Nur
Autor Mejor respuesta

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
Descartar
Avatar
XOLUTO
Mejor respuesta

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
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Custom Button in Tree View
treeview button
Avatar
Avatar
1
may 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 Resuelto
wizard button
Avatar
Avatar
1
nov 16
6862
open wizard from tree view
wizard treeview
Avatar
Avatar
1
ene 16
8016
How to add a single button in tree view ?
treeview button
Avatar
Avatar
1
mar 15
16870
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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