Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

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?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
2 Respostes
13561 Vistes
Avatar
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
Avatar
Descartar
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

Avatar
Serge Mercado
Autor Best Answer

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

Avatar
Paresh Wagh
Best Answer

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
Avatar
Descartar
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!

Registrar-se
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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