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

Odoo 15 - client side input for function triggered by button

S'inscrire

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

Cette question a été signalée
functionbuttonsbuttoninputv15
1 Répondre
4839 Vues
Avatar
Fred Nunes

Hi everyone,

I want to have a button on one of my form views that triggers a function in the backend. This function has a couple of parameters, and I want these parameters to be passed live by the user, when clicking the button.

Is there a way to implement this on Odoo? The perfect scenario would be:

  • the user clicks the "Trigger Function" button
  • a prompt opens up with two fields (can be a TransientModel, although I never want the user input to be stored in the database, so ideally it should be passed directly to the backend)
  • the function runs with these two parameters, and the output of the function is used to fill a field in the original record
  • the original form view stays open

Any ideas would be greatly appreciated


1
Avatar
Ignorer
Avatar
Amr Abd-Alkrim (FireBits)
Meilleure réponse

Yes you can do this through Odoo Wizards here is my full code in github gists.

To make a wizard you have to use the TransientModel witch will store the data temporarily in the database and it will be vacuumed after a while 

in your_module/wizards/wizard.py

class PopupWizard(models.TransientModel):
    _name = 'popup.wizard'
    
    title = fields.Char()
    start_date = fields.Datetime()
    
    def confirm(self):
      # to get the title value
      your_variable = self.title       # do what you want with the self.env to update any record you want    
      return {
            'name': "Your action name",
            'type': "ir.actions.act_window",
            'res_model': "your_model,
            'view_type': "form",
            'view_mode': "tree,form",
            'form_view_id': "your_form_external_id"
            'help': "help text",
       }


then in your form you can create a button that takes the action id with the %d function 


Happy to help :) an upvote will be awesome

2
Avatar
Ignorer
Fred Nunes
Auteur

Hi, I really appreciate your comment :-) this is the approach I was thinking about following, as I've written a few wizards, but at the time I didn't understand how to avoid having to write the input to the database (which can easily be prevented by overriding the create method).

My situation at the moment is the following: I have my model (Model X) and this model has a button in each record's form view. This button needs to:

* open the form view for the PopupWizard, which I believe can be done be returning the right action in the Python code
* the user inserts some input into the popup wizard and presses the confirm button (as you have done in your gist)
* upon pressing the confirm button, the code needs to go back to the original record of Model X and modify it in a certain way

My question is: how do I keep track of the ID of the original record? Is it possible to do this by passing context to the Popup Wizard action?

Thanks!

Amr Abd-Alkrim (FireBits)

When you click on the done button on your wizard you can return an action from your wizard method and it will open the form again for you just like refresh i updated my answer with the action

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é
send email button does not send immediately odoo15 Résolu
function community email buttons v15
Avatar
Avatar
1
juin 23
2246
i want to know about buttons in odoo Résolu
buttons v15
Avatar
Avatar
1
juin 22
3935
How to add a button to the bar from the top ?
buttons button
Avatar
Avatar
Avatar
2
juil. 15
7433
api request
function api button
Avatar
0
déc. 24
2073
How to add button under action?
form buttons v15
Avatar
Avatar
1
avr. 23
112
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