Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

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?

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
13567 Views
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
Discard
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
Author

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
Author

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

Please disregard my other comment.

Serge Mercado
Author

The buttons were added using this:

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

Serge Mercado
Author

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
Author 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
Discard
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
Discard
Serge Mercado
Author

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
Author

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
Author

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
Author

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
Author

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!

Sign up
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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