Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How do i get active_id in my one2many field ?

Odoberať

Get notified when there's activity on this post

This question has been flagged
4 Replies
14150 Zobrazenia
Avatar
Kalmen Chia

Hi ,

i have a class that look something like this.

class myclass(osv.Model):
    _name="myclass.class1"

    def _get_cur_subline_ids(self, cr, uid, ids, field_name, arg, context): {
       //i need my current active class_line id here !!!
       print context
       //expecting to get model_line_id in the context but cannot
    }

    def _srch_subline(self, cr, uid, obj, name, args, context):: {
       //i need my current active class_line id here !!!
       print context
       //expecting to get model_line_id in the context but cannot
    }      

    _columns = {
                "name" : fields.char('Desc.',help="enter your description"),
                "class_line_ids" : fields.one2many('class.line', 'class_id', 'Lines'),
                "lines_subline_ids" : fields.function(_get_cur_subline_ids,
                                         type='one2many',
                                         obj="product.product",
                                         method=True,
                                         string='Products List'
                                         fnct_search=_srch_subline),
                }
myclass()

XML for myclass

<field name="class_line_ids" nolabel="1"  context="{'model_line_id': active_id}">

My questions is , how can i get the ACTIVE id of my class_line_ids i.e. when user click on the tree view of the class_line_ids in my form and pass it to the context and then in turn to be used by either the _get_cur_subline_ids or _srch_subline function to filter the return ids of the object "product.product" dynamically ?

1
Avatar
Zrušiť
Avatar
Amit Parik (amp)
Best Answer

Hello,

You can pass the active_id on context for tree view where you have set the widget="one2many_list" on the attribute you can pass the active_id on context.

As well on any method, If you want to use the active_id, You have to use get the active id from the context by using context.get('active_id').

Thank you!

2
Avatar
Zrušiť
Kalmen Chia
Autor

Not sure whether is bugs , after apply this https://code.launchpad.net/~openerp-dev/openerp-web/7.0-opw-584668-cpa patch , follow where i add context="{'model_line_id': active_id}" at my class_line_ids field , but cannot get the context at the function in my py.

Manish Bohra

Hello Amit,

You have any idea how to get active model name for 'One2Many' field ??

For Example when i am apply above condition you are suggest like in tree view i am apply active_model then i will get 'sale.order' but how to get 'sale.order.line'.

Avatar
Pawan
Best Answer

kalmenchia,

Actualy what you are trying to do is not correct, you can't get the active_id(which according to your requirement is line id from one2many  'class_line_ids') in main object..

as active_id for current object(myclass.class1) fields will be current record id only.. so anywhere writing active_id means you are pointing to myclass.class1 object..

One thing you can do is in xml on field 'class_subline_ids' pass 'class_line_ids' in context...

<field name="lines_subline_ids" nolabel="1"  context="{'model_lines': lines_subline_ids}">

and then use this lines in context at your '_get_current_subline_ids' and '_srch_subline'


Hope it helps    


0
Avatar
Zrušiť
Avatar
Omar OUHARI
Best Answer

Hello,

Did you find any solution ?

I have the same issus.

Please let me know if there is any way to retrieve active_id on one2many fields.

Thanks.

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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