Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How can I get the "active_ids" from tree view in Odoo 11?

Odebírat

Get notified when there's activity on this post

This question has been flagged
5 Odpovědi
21468 Zobrazení
Avatar
SUON Sroeurn

Dear Odoo developers,

I used code as hereby: self._context.get('active_ids'), self.env.context.get('active_ids'), self._context.get('active_ids',[]), self.env.context.get('active_ids',[]) in order to get the active_ids from tree view, but I cannot get the result as I expected.

Kindly let me know to get these "active_ids".

Thank you in advance!

Best regards,

Sroeurn Suon


0
Avatar
Zrušit
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Nejlepší odpověď

Hi Sroeurn,

Your question misses some context about in what case you exactly want to do it. Here is an example with an action. XML:

    <record id="ir_actions_server_custom" model="ir.actions.server">
        <field name="name">Your action</field>
        <field name="type">ir.actions.server</field>
        <field name="model_id" ref="model_stock_picking"/>
        <field name="state">code</field>
        <field name="code">
            if records:
                action = records.your_action()
        </field>
        <field name="binding_model_id" ref="your_module.model_stock_picking"/>
    </record>

Python:

    @api.multi
    def your_action(self):
        active_ids = self.ids 

In general you usually get the active ids out with self.env.context.get like this:

active_ids = self.env.context.get('active_ids', [])

You can see a lot of examples in Odoo at https://github.com/odoo/odoo/search?q=active_ids&unscoped_q=active_ids have a look there too.

Regards,
Yenthe

3
Avatar
Zrušit
SUON Sroeurn
Autor

Dear Mr. Yenthe,

Thank you, I used the same as your code, but I cannot get the result.

ids = self.env.context.get('active_ids', [])

I think that maybe I missed some configuration?

Thank you in advance.

Best regards,

Sroeurn

Avatar
Jignesh Mehta
Nejlepší odpověď

Hello Sroeurn Suon,

For the active_ids, You can create wizard models and form view and also creates the act_window for that wizard, From that you can used the active_ids which is selected records from tree.

For Example :

wizard.py :-
from odoo import models, fields, api

class WizardModel(models.TransientModel):
    _name = 'wizard.model'

    name = fields.Char ('Name')

    @api.multi
    def wizard_method(self):
        self.ensure_one()
        sale_order_ids = self.env['sale.order'].browse(self._context.get('active_ids'))
        print "sale_order_ids ::::: ", sale_order_ids

wizard_view.xml :-
<record id="wizard_model_view" model="ir.ui.view">
    <field name="name">wizard.model.form.view</field>
    <field name="model">wizard.model</field>
    <field name="arch" type="xml">
        <form string="Wiard">
            <group>
                <group>
                    <field name="name" required="1"/>
                </group>
                <group/>
            </group>
            <footer>
                <button name="wizard_method" string="Ok" type="object" class="oe_highlight"/>
                or
                <button string="Cancel" class="oe_link" special="cancel"/>
            </footer>
        </form>
    </field>
</record>

<record id="action_wizard_model" model="ir.actions.act_window">
    <field name="name">Wizard Model</field>
    <field name="res_model">wizard.model</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
</record>

<act_window id="multi_wizard_model" multi="True" name="Multi Wizard" res_model="wizard.model" src_model="sale.order" view_mode="form" target="new" view_type="form"/>


Here res_model : wizard.model name

        src_model : For you create act_window


When you selected multiple sale.order from tree view, In action view You can see Menu which is Multi Wizard, so from that open wizard and when click on OK, You can use active_ids for selected sale.order


Hope it will works for you.

Thanks,

3
Avatar
Zrušit
Serge Mercado

Thank you, Jignesh! I was able to use this in Odoo 13 with slight changes.

src_model is changed to binding_model.

multi="True" is unnecessary and will not work in Odoo 13.

Here's my code:

<act_window id="multi_production_batch_wizard"

name="Production Batch"

binding_model="mrp.production"

res_model="production.batch.wizard"

view_mode="form"

target="new"

/>

Avatar
Herbert Ichama
Nejlepší odpověď

def _default_active_ids(self):
return self.env['your_model'].browse(self._context.get('active_ids'))
​

#A relation btn the Transient model and the Actual model

name = fields.Many2one('model_name', string='name', required=True, default=_default_active_ids)

This should be able to help you


2
Avatar
Zrušit
Avatar
SUON Sroeurn
Autor Nejlepší odpověď
Dear Mr. Yenthe,
Now I can get the active_ids from the tree view successfully, following your guideline.
Thank you very much. :-)
Best regards,
Sroeurn
0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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