Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Wizard and context values in OpenERP 7

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
wizardv7context
3 Besvarelser
21394 Visninger
Avatar
Francesco OpenCode

When I read the context in the functions of a wizard, I found that active_id is the wizard id. In the old openerp version, this parameter was the form id when i call wizard! It'a a bug or a feature? There is a system to read the calling form id?

1
Avatar
Kassér
Avatar
Francesco OpenCode
Forfatter Bedste svar

I found my problem!!! I created a multi-step wizard. After the first step, I forgot to pass context to new step. Therefore, the context was replaced by a standard context where active_id was wizard id. Now I've replaced my old code with this:

return {
 'type': 'ir.actions.act_window',
 'name': "Inserisci Ispezioni Settimanali",
 'res_model': 'gmc.inserisci_ispezioni_settimanali',
 'res_id': ids[0],
 'view_type': 'form',
 'view_mode': 'form',
 'view_id': view_id,
 'target': 'new',
 'nodestroy': True,
 'context' : context,
 }

and now work fine.

3
Avatar
Kassér
Lucio

But...with this you are getting the id of the wizard, not the form id of the caller. I think I am understanding the answer incorrectly.

arsalan

Hi I am also having problem in calling form through my button . Plz help

Avatar
Lucio
Bedste svar

I can not say if this is a bug or a feature actually, but to solve this I had to override the default_get function of the wizard.

E.g. Lets assume we want to set a field something of the caller.model object calling a wizard. In field called caller_id we will put the caller's id, not showing it in any view. Now let us assume that the function action_of_wizard is the one that does 'the magic' and is called when pressing a button.

Then in wizard .py:

_columns = {    
    ...
    something: fields.char("Data to write in the caller's field", required=True),
    caller_id: fields.integer('Caller ID', readonly=True),
    ...
}

def default_get(self, cr, uid, fields, context=None):
    ret = super(wizard_model_name,self).default_get(cr, uid, fields, context=context)
    caller_id = context.get('active_id',False)
    if caller_id:
        ret['caller_id'] = caller_id
    return ret

def action_of_wizard(self, cr, uid, ids, context=None):
    ...
    caller_pool = self.pool.get('caller.model')
    for wiz in self.browse(cr,uid,ids,contex=context):
        caller_pool.write(cr, uid, wiz.caller_id, {'caller_field': wiz.something})
        ...
    return {'type': 'ir.actions.act_window_close'}

There are some possible improvements to make to the code, of course, but I hope I made myself clear from the above example!

Hope this answer suits your enquiry!

5
Avatar
Kassér
Francesco OpenCode
Forfatter

This is not a solution for me because I need form id to write some datas in the record and not to set wizard field.

Lucio

I updated my answer to do what (I think is what) you want.

Mohammad Alhashash

I think you mean default_get(), not get_default()

Lucio

My bad! :P Sorry

Francesco OpenCode
Forfatter

No guys. This is not my case. I need to write wizard datas in form fields. But i haven't the form id in wizard context.

Lucio

Exactly, you wont have it in the context once the wizard is loaded, but before (when calling default_get) you can access the ID of the form as stated in the answer, save it an integer field of the wizard and use it again when you need it. I can not see why this is not working, it does in my case at least.

Mohammad Alhashash

You do not need to override default_get() to set a field value. Just add default_FieldName to the context attribute.

Lucio

Yes, this is true, you can do it like this. It did not occur to me but this is probably simpler if the only thing you want to do is access the id of the caller. I did that way but because in my case I was doing other calculations as well. Thanks for pointing this

Avatar
Mohammad Alhashash
Bedste svar

If you are using a button to open the wizard, you can control the default values of the wizard fields using context variables in the format default_FieldName.

So, If the wizard has a field called target_id; In your model, you should start the wizard using a method button like this:

def action_start_wizard(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    context.update({
        'default_target_id': len(ids) and ids[0] or False
    })
    return {
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'mymodule.mywizard',
        'type': 'ir.actions.act_window',
        'target': 'new',
        'context': context,
        'nodestroy': True,
    }

Then, use the target_id field in your methods instead of context['active_id']. Of course you should make target_id field invisible in the wizard view.

0
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
field value in context
wizard fields v7 context
Avatar
0
mar. 15
4541
Force wizard dimension Løst
wizard v7
Avatar
1
apr. 24
9304
active_domain not found in context when using wizard
wizard context
Avatar
0
aug. 17
4079
Form not updating on button action
wizard v7
Avatar
Avatar
1
mar. 15
6742
Fetch values from dynamic view of a wizard
wizard v7
Avatar
Avatar
Avatar
2
mar. 15
5686
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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