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 do I add a button in tree view that calls a wizard and gets the ids of the records selected in the tree view?

Abonare

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

Această întrebare a fost marcată
2 Răspunsuri
13570 Vizualizări
Imagine profil
Serge Mercado

In manufacturing order model, I added new buttons beside create (Produce button, and Mark as Done button). I wanted the "Produce" button to pop up a wizard that will ask for a res.user and after clicking Save button, it will write the res.user to each records. How can I make this possible?

3
Imagine profil
Abandonează
Sudhir Arya (ERP Harbor Consulting Services)

Where do you want to write the user record? To MRP record or consumed lines or finished product or somewhere else?

Note: To update any record, you can use write method.

Sehrish

Open wizard on button click: https://learnopenerp.blogspot.com/2020/01/open-wizard-on-button-click-in-odoo.html

Serge Mercado
Autor

Hello, Sudhir and Sehrish!

The button that I meant to describe are these buttons added above the tree view.

https://imgur.com/a/tWf2cst

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

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

<button t-if="widget.modelName == 'mrp.production'" class="btn btn-primary oe_produce_button" type="button" accesskey="f">Produce</button>

Serge Mercado
Autor

<blockquote class="imgur-embed-pub" lang="en" data-id="a/tWf2cst" data-context="false" ><a href="//imgur.com/a/tWf2cst"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

Serge Mercado
Autor

Please disregard my other comment.

Serge Mercado
Autor

The buttons were added using this:

https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11

Serge Mercado
Autor

The function of that wizard will link the mrp.production to a custom model I named production.batch. Before this custom model is created, it will ask for a an attachment to be uploaded. Once I clicked save, all the records of mrp.production's field called production_batch will be filled with that of the wizard.

This is how I implemented the wizard (works on server action):

https://imgur.com/sYEVY2h

Imagine profil
Serge Mercado
Autor Cel mai bun răspuns

Just an update! This can now be implemented in Odoo 14 by adding a button in the header of a tree view.

<record id="my_view_id" model="ir.ui.view">
<field name="name">view.name</field>
<field name="model">my.model</field>
<field name="arch" type="xml">
<tree>
<header>
<button name="%(action_for_wizard)d" string="Action" object="action"/>
</header>
</tree>
...

When a record is selected:



When no record is selected:


3
Imagine profil
Abandonează
Tri Nanda

This working on Odoo14 as like what I want.

Thanks,
Tri Nanda

Niyas Raphy (Walnut Software Solutions)

Sharing a video example o the same: https://www.youtube.com/watch?v=R8eG6uOxHKw

Imagine profil
Paresh Wagh
Cel mai bun răspuns

Hi Serge: If I have understood your question correctly, you should be able to loop through the variable "self" that gets passed to each action to get what you need.

EDIT:

Actions can be linked to buttons in one of two ways depending on where the action is defined.

If the action is defined as a server action, you can use the following syntax:

<button name="SERVER_ACTION_ID" type="action" string="BUTTON LABEL"/>

NOTE: type="action" and name=id of the server action.

The server action id can be defined to be automatically picked up at installation time (instead of hard coding it) by using the syntax

%(EXTERNAL_ID_OF_SERVER_ACTION)d

For example,

<button name="%(stock.action_stock_report)d" type="action" string="Stock Report"/>

If the action is defined as a function in the underlying object, you can use the following syntax:

<button name="FUNCTION_NAME" type="object" string="BUTTON LABEL"/>
NOTE: type="object" and name=name of the function defined in the python class of the object
1
Imagine profil
Abandonează
Serge Mercado
Autor

I just realized my question is incomplete, but thank you for this Paresh! This is a step further for what I was aiming for.

Serge Mercado
Autor

Hello, Paresh! What I did that worked is that I created a server action using a wizard <act_window ... />

I was referring to this tutorial at first:

https://www.odoo.com/fr_FR/forum/aide-1/how-can-i-get-the-active-ids-from-tree-view-in-odoo-11-143922

but the multi="True" is not necessary anymore and won't work in Odoo 13, and the attribute src_model is now binding_model. This is the code I used:

<act_window id="multi_production_batch_wizard"

name="Create Production Batch"

binding_model="mrp.production"

res_model="production.batch.wizard"

view_mode="form"

target="new"

/>

I was able to retrieve the selected ids using:

manufacturing_orders = self.env['mrp.production'].browse(self._context.get('active_ids'))

Serge Mercado
Autor

It only solved half of the problem, I want to implement that server action into a new button using this:

https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11

I don't know how to call a wizard by extending the ListView.buttons as shown here: https://imgur.com/a/tWf2cst

Paresh Wagh

Hi Serge: I have edited my earlier answer and added an explanation of how to link an action to a button.

Serge Mercado
Autor

Hello Paresh, how do I implement that if the button used is like in the link below? I added a custom ListView buttons

https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11

Serge Mercado
Autor

Hello, Paresh! This is working now in Odoo 14 since they added a header for the tree view already. Thank you!

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
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