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 to pass active id to a popup

Odebírat

Get notified when there's activity on this post

This question has been flagged
context7.0active_id
2 Odpovědi
15550 Zobrazení
Avatar
Luis Filipe Castanheira

Hi, I am trying to pass the active id to a popup window so that in my function I can access the actual state of the caller object.

For that, I'm doing the following. In XML view:

<page string="Opinions">
    <field name="opinion_ids" context="{'generic_request_id': active_id}" >
        <tree delete="false"> 
            <field name="request_state" />
            <field name="opinion_request_date" />
            <field name="requestor" />
        (...)

In python I have:

_defaults={
    'state': 'requested',
    'opinion_request_date': lambda *a: datetime.date.today().strftime('%Y-%m-%d'),
    'request_state': lambda self, cr, uid, context: self._get_request_state(cr, uid, context=context), #store the state of the request when opinion was asked
    (...)
}
(...)
def _get_request_state(self, cr, uid, context=None):
    ids = context.get('generic_request_id', False)
    #import pdb; pdb.set_trace()        
    return self.pool.get('generic.request').browse(cr, uid, ids, context).state

In pdb I realize that "ids" is False because there is no generic_request_id variable in context...

(Pdb) p ids
False

(Pdb) p context
{'lang': 'en_US', 'no_store_function': True, 'tz': False, 'uid': 1}

Anyone knows a way to do this?

0
Avatar
Zrušit
Avatar
Luis Filipe Castanheira
Autor Nejlepší odpověď

I finally managed to solve this in a very tortuous way. If anyone has a more straight forward way to do this, please help!

So, what I did was, create and save the opinion request and, in the function called by the workflow (request_opinion), I call an other function that checks the id of the request associated to this opinion an then it's actual state and, finally, updates the value in the opinion table.

Here is the code:

class opinion(osv.osv):
    _name='opinion'
    _description='opinion'
    _columns={
    (...)
        'state': fields.selection([('requested','Requested'),
            ('reviewing','Reviewing'),
            ('issued','Issued'),
            ('added','Added to the request')],
            'Status', readonly=True, track_visibility='onchange',
        ),
    (...)
        'request_state': fields.selection([('draft','Draft'),
            ('submitted','Submitted - Waiting for confirmation'),
            ('req_reformulation', 'Reformulation'),
            ('confirmed', 'Confirmed - Processing'),
            ('treatment', 'Processing'),
            ('wauth', 'Awaiting authorization'),
            ('wappr', 'Awaiting approval'),
            ('authorized','Authorized'),
            ('closed', 'Request closed'),
            ('closed_auth', 'Closed - Authorized'),
            ('closed_appr', 'Closed - Approved'),
            ('closed_disappr', 'Closed - Disapproved'),
            ('closed_nconf', 'Closed - Not confirmed'),
            ('closed_ref', 'Closed - Refused'),
            ('denied','Denied')],
            'Request Status', help="Status of the request when the opinion was requested", readonly=True, track_visibility='onchange',
        ),
        'generic_request_id': fields.many2one('generic.request', 'Request', required=True),
    }

    def _get_request_state(self, cr, uid, ids, context=None):
        res={}
        op = self.browse(cr, uid, ids, context=context)
        req_id = op[0].generic_request_id.id
        req = self.pool.get('generic.request').browse(cr, uid, req_id, context)
        #import pdb; pdb.set_trace()
        self.write(cr, uid, ids, {'request_state': req.state })
        return True

    def request_opinion(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids, {'state': 'requested'})
        self._get_request_state(cr, uid, ids, context=context)
        return True

As I said before, if someone has a better sugestion to do this a more effective way, feel free to share!


Edit:

Changed it to be a little more effective (no need to call the _get_request_state() anymore). But still if anyone has better way to do this, fill free to share!

def request_opinion(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'requested', 'request_state': self.browse(cr, uid, ids, context=context)[0].generic_request_id.state })
    #self._get_request_state(cr, uid, ids, context=context)
    return True
0
Avatar
Zrušit
Avatar
Weste
Nejlepší odpověď

I think you have to put your context="{'generic_request_id': active_id}" in the button that calls the wizard.

0
Avatar
Zrušit
Luis Filipe Castanheira
Autor

Thanks for the quick answer, but in this case I have no buttons... The popup is opened by the "Add an item" present in the tree view of the page refering to "opinion" in my "generic request" form view.

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
Related Posts Odpovědi Zobrazení Aktivita
Not getting selected records from active_ids, returns empty list
pdf context active_id env
Avatar
0
zář 23
2000
Using both ref and active_id at once in record field? Vyřešeno
refrence context active_id eval
Avatar
1
led 22
9066
context not work ???
context
Avatar
Avatar
1
led 25
2096
How to get Active_id after url action
action context url active_id Actions
Avatar
Avatar
1
dub 24
2589
how to pass context from XML to JavaScript?
javascript xml context active_id pass
Avatar
Avatar
Avatar
2
pro 23
13597
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