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

Return wizard from a function

Tilmeld

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

Dette spørgsmål er blevet anmeldt
5832 Visninger
Avatar
Celia

How can I call a wizard in a return of a function? 

This is the first wizard that appears: 

class get_ticket(osv.osv_memory):    
    _name = 'get.tickets.wizard'    

    def _tickets_control(self, cr, uid, context=None):         active_ids = []         partner_ids = {}         for active_id in context.get('active_ids'):             active_ids.append(active_id)             for partner_id in self.pool.get('tickets').browse(cr, uid, active_id, context=context).partner_id:                 partner_ids[partner_id.id] = partner_id.id         if len(active_ids) <= 1:             self.display_error_message(cr, uid, 'You have to select more than 1 tickets.')             return False          elif len(partner_ids) > 1:             self.display_error_message(cr, uid, 'You have selected 2 or more tickets of different partners.')             return False         return True
    
    def display_error_message(self, cr, uid, error, context=None):         view_id = self.pool.get('ir.model.data').get(cr, uid, 'get_ticket_wizard', 'close_wizard_form_view', context=context)         view_id = view_id[0]         return {             'name': _("Error"),             'view_type': 'form',             'view_mode': 'form',             'view_id': view_id,             'res_model': 'close.wizard',             'type': 'ir.actions.act_window',             'target': 'new',             'context': {'error': error},     }     _columns = {         'ticket_id': fields.many2one('tickets', string='Ticket to keep'),         'control': fields.boolean(compute='_tickets_control'),     }     def onchange_get_tickets(self, cr, uid, ids, context=None):         active_ids = []         for active_id in context.get('active_ids'):             active_ids.append(active_id)         return {'domain': {'ticket_id': [('id', 'in', active_ids)]}}     _defaults = {         'control': _tickets_control,     }

And this is the wizard that I want to call (that has the function like an error message and close the wizard before and this [this I don't know if really does it]): 

class close_wizard(osv.osv_memory):    
    _name = 'close.wizard'    

    def _display_error(self, cr, uid, ids, context=None):        
        return context.get('error')    

    def _close_window_wizard(self, cr, uid, ids, context=None):         return {'type': 'ir.actions.act_window_close'}     _columns = {         'error': fields.char(string=''),     }     _defaults = {         'error': _display_error,     }

And this is its view: 

<!-- ********** Form view of close wizard ********** -->
<record model="ir.ui.view" id="close_wizard_form_view">    
    <field name="name">close.wizard.form</field>    
    <field name="model">close.wizard</field>    
    <field name="arch" type="xml">        
        <form string="Error">            
            <group>                
                <field name="error"/>            
            </group>            
            <footer>                
                <button string="Accept" name="%(_close_wizard_window)d" type="action" class="oe_highlight"/>         
            </footer>        
        </form>    
    </field>
</record>
<!-- ********** Option get tickets in menu 'More' ********** -->
<act_window id="close_wizard_action"            
    multi="True"            
    key2="client_action_multi"            
    name="Error"            
    res_model="close.wizard"            
    src_model="get.tickets.wizard"            
    view_mode="form"            
    target="new"            
    view_type="form"/>


0
Avatar
Kassér
Emipro Technologies Pvt. Ltd.

Can you explain your main objective to achieve from wizard ? It will help us to understand your code as well as your requirement. Based on that we can give you exact suggestion or solution.

Celia
Forfatter

The module that I'm developing has the objective to have tickets as part of after-sales services. That tickets can being fused or separated in 2 tickets and other actions. Here I'm going to fuse 2 tickets, to do this I have to check 2 tickets in the tree view and in the 'more' button I have an option 'Fuse tickets' that call the wizard (get.tickets.wizard), here appears the wizard that has a many2one where I have to select the ticket that I want to preserve (the other is going to go over to another status, that is fused), but if the tickets that I have checked are of differents partners I have to display a message with the error, and I have to close the message error and the wizard when the user press the 'accept' button. So in code is: I call _tickets_control function, and if is something wrong (like the tickets have differents partners), this function calls display_error_message function that has to return the error message wizard (or window or view)

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
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