Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Wizard and context values in OpenERP 7

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
wizardv7context
3 Réponses
21401 Vues
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
Ignorer
Avatar
Francesco OpenCode
Auteur Meilleure réponse

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
Ignorer
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
Meilleure réponse

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
Ignorer
Francesco OpenCode
Auteur

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
Auteur

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
Meilleure réponse

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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
field value in context
wizard fields v7 context
Avatar
0
mars 15
4546
Force wizard dimension Résolu
wizard v7
Avatar
1
avr. 24
9313
active_domain not found in context when using wizard
wizard context
Avatar
0
août 17
4080
Form not updating on button action
wizard v7
Avatar
Avatar
1
mars 15
6745
Fetch values from dynamic view of a wizard
wizard v7
Avatar
Avatar
Avatar
2
mars 15
5695
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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