Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Add Custom Button To List View Header

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
listviewbuttonodoo-update
6 Réponses
51862 Vues
Avatar
Daniel Kauffman

In Odoo, when viewing a model in list view, buttons to "Create or Import" are usually displayed near the top of the page. Instead of these buttons, how would I display a custom button in this exact location on the page, when viewing my model in list view? I have a model that is read-only and would like to display a button to force synchronization of the model.

3
Avatar
Ignorer
Niyas Raphy (Walnut Software Solutions)

In latest odoo versions, it can be achieved easily as we do in form view, see: https://www.youtube.com/watch?v=R8eG6uOxHKw

Avatar
Axel Mendoza
Meilleure réponse

This require to develop an extension in the template and javascript widget, like this:

You need to include a template that insert the button like:

<t t-extend="ListView.buttons">
<t t-jquery="button.oe_list_add" t-operation="after">
<button class="oe_button oe_new_button oe_highlight" type="button">New Button</button>
</t>
</t>

Next you need to extend the widget ListView like this:

instance.web.ListView.include({
    load_list: function(data) {
if (this.$buttons) {
this.$buttons.find('.oe_new_button').click(this.proxy('do_new_button')) ;
}
},
do_new_button: function () {
//implement your clic logic here  
}
});

This is an example of course

7
Avatar
Ignorer
Daniel Kauffman
Auteur

Like so? https://www.odoo.com/documentation/8.0/howtos/web.html

Axel Mendoza

see an example in the updated response

Andre de Kock

Will this code add the button for *all* tree views?

Axel Mendoza

Yes. But you could restrict the visibility using options for the template

Ưng Tú

thanks for your solution but when i click on button, show error: "Traceback:

Error: Couldn't find method 'do_new_button' in widget". Can u show me when my error

Thank you agian and have a nice day

Herve

@Ưng Tú : same for me, and I'm messing around this issue ...

Avatar
Taha ZIADEH
Meilleure réponse

In Odoo 11, here is how to achieve this:
Let's say we want to add special filtering functionality through a button
First create a template that is responsible of displaying the button :

<?xml version="1.0" encoding="UTF-8"?>

<template xml:space="preserve">

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

<t t-jquery="button.o_list_button_add" t-operation="after">

<button t-if="widget.modelName == 'your.model.name'" type="button" class="btn btn-primary btn-sm oe_filter_button" accesskey="f">

Advanced Filters

</button> 

</t>

</t>

</template>

P.S.:Don't forget to add the file containing the above template to the manifest
So far the button will be available but not functional. In order to make it functional, you have to add javascript support for its click event :

odoo.define('whatever.filter_button', function (require) {

"use strict";

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

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

ListController.include({

renderButtons: function($node) {

this._super.apply(this, arguments);

if (this.$buttons) {

let filter_button = this.$buttons.find('.oe_filter_button');

filter_button && filter_button.click(this.proxy('filter_button')) ;

}

},

filter_button: function () {

console.log('yay filter')

//implement your click logic here

}

});

})

Then, load the javascript file you wrote as a script like:

<template id="assets_backend" name="whatever_name assets" inherit_id="web.assets_backend">

<xpath expr="." position="inside">

<script src="/your_module_name/static/src/js/filter_button.js" type="text/javascript"/>

</xpath>

</template>

For further implementation details, don't hesitate to post your comments or questions :)

3
Avatar
Ignorer
gain charlie

Hi , How to do this in Odoo 12?

Avatar
Adil Akbar
Meilleure réponse

Hi, you can follow this: 


hope it helps

0
Avatar
Ignorer
Avatar
Jerry zhang
Meilleure réponse

How do I add this button to Kanban View Header? Thanks

0
Avatar
Ignorer
Avatar
Adrian Nicorici
Meilleure réponse

@Taha ZIADEH

In my case it did not work until i added at the end:

core.action_registry.add('product.template.custom_filter', ListController);
// return the object.
return ListController;

JS file looks like this:

odoo.define('product.template.custom_filter', function (require) {

"use strict";
console.log('something');
var core = require('web.core');
console.log('require list controller');
var ListController = require('web.ListController');
console.log('list controler: ' + ListController);
ListController.include({

renderButtons: function($node) {

this._super.apply(this, arguments);

if (this.$buttons) {

let filter_button = this.$buttons.find('.oe_filter_button');

filter_button && filter_button.click(this.proxy('filter_button')) ;

}

},

filter_button: function () {
console.log('yay filter');
}

});
console.log('registering');
core.action_registry.add('product.template.custom_filter', ListController);
// return the object.
return ListController;
})



0
Avatar
Ignorer
Avatar
Emipro Technologies Pvt. Ltd.
Meilleure réponse

Hello Daniel,

You can refer to account module & following files

  • /account/static/src/js/account_move_line_quickadd.js

  • /account/static/src/xml/account_move_line_quickadd.xml

This will not add the button at exact location where you wanted, but still can help you.

Hope this helps.

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Inline Edit button near create
xml listview button js
Avatar
0
juil. 21
3003
How easy is it to add a button to mark Tasks as complete (in the List View)? v13 Résolu
listview task button customization
Avatar
Avatar
1
juin 20
6200
How to Implement Column-wise Filters in CRM List View (Odoo 18)
listview
Avatar
Avatar
1
août 25
1489
Opening new window with button in OpenERP Résolu
button
Avatar
Avatar
1
janv. 24
15157
How to Add custom button on each row of list view that can redirect to another list view?
listview report button technical odoo
Avatar
Avatar
1
nov. 22
5158
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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