Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

I can't understand how wizards work

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
wizardsodooV8
2 Respuestas
11214 Vistas
Avatar
Uillino

I'm trying to create a wizard, but I'm confused about how a wizard works.

This is mymodule.py:

# -*- encoding: utf-8 -*-
from openerp import models, fields

class mymodule_attivita(models.Model):
_name = 'mymodule.tbl_attivita'
_description = 'Tabella Attivita'

scode_attivita_contr = fields.Char('Code', size=1, required=True)
sdescrizione = fields.Text('Descrizione', equired=True)

and this is mymodule_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_mymodule_attivita" model="ir.ui.view">
<field name="name">mymodule view</field>
<field name="model">mymodule.tbl_attivita</field>
<field name="arch" type="xml">
<form string="mymodule Attivita">
<sheet>
<notebook>
<page string="Tab 1">
<group name="top">
<group name="left">
<field name="scode_attivita_contr"/>
<field name="sdescrizione"/>
</group>
</group>
</page>
<page string="Tab 2">
<group name="top">
<group name="left">
<field name="id" attrs="{'invisible': [('write_date', '=', False)]}"/>
<field name="write_date" attrs="{'invisible': [('write_date', '=', False)]}"/> 
</group>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
               <act_window id="action_bridge_attivita" name="Attivita" res_model="mymodule.tbl_attivita" view_mode="tree,form" />
                <menuitem id="menu_mymodule_attivita" name="Menu mymodule Attivita" parent="mail.mail_feeds" sequence="20" action="action_mymodule_attivita" />
 
    </data>
</openerp>

So, I have a form with 2 fields (plus id and write_date that I've set invisible).

I would like to create a wizard to open a page with a button Pushing this button, Odoo has to open the model 'mymodule.tbl_attivita'. So, I've written this wizard.py file:

# -*- encoding: utf-8 -*-
from openerp import models, api

class wizard(models.TransientModel):
_name = 'mymodule.wizard'
_description = "Wizard

@api.multi
def crea_attivita(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'mymodule.tbl_attivita',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
}

with this wizard_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_mymodule_wizard_form" model="ir.ui.view">
<field name="name">Wizard</field>
<field name="model">mymodule.wizard</field>
<field name="arch" type="xml">
<form string="mymodule Wizard">
<sheet>
<group name="top">
<group name="left">
<h1>Demo Wizard</h1>
</group>
<group name="right">
<button type="object"
name="crea_attivita"
string="Create Attivita"/>

                                                </group>
                                     </group>
                             </sheet>


<footer>

<button string="cancella" special="cancel"/>

</footer>

</form>

</field>

</record>


<record id="view_mymodule_wizard" model="ir.actions.act_window">

<field name="name">Select link</field>

<field name="type">ir.actions.act_window</field>

<field name="res_model">mymodule.wizard</field>

<field name="view_type">form</field>

<field name="view_mode">form</field>

<field name="target">new</field>

</record>

 

<act_window id="action_mymodule_wizard" name="Attivita" res_model="mymodule.wizard" view_mode="tree,form" /> 

<menuitem id="menu_mymodule_wizard" name="Menu mymodule Wizard" parent="mail.mail_feeds" sequence="40" action="action_mymodule_wizard" />

</data>

</openerp>

In this way, I have a link 'Attivita' in the 'Messaging' menu. When I click on it, I open the wizard and I could click on 'Create' and then I could click on the button 'Create Attivita'. At this point, I have a pop up with the field of the model mymodule.tbl_attivita, without the option for saving my data.

I think that there is something about wizard that I haven't understood. Could anyone explain me what is missing?

1
Avatar
Descartar
Avatar
Bole
Mejor respuesta

First you need to understand the difference between models.Model and models.TransientModel... 

models.Model class is intended for permanently storing data in database... 

models.TransientModel is intended for temporary data, very simmilar to sql view , and most wizards will use TransientModel for storing data.. this is the main reason why you do not have option to save the data while on wizard screen.

If i got your need right, you would like to create some activity record and store it in database... 
If that is so, you should create a view on models.Model subclass (tbl_attivita! ) and you have no need to create a wizard.. 

That view can be opened as a popup window the way you opened wizard class (your code) but the class itself should be Model instead of TransientModel...


hope it helps a bit.. 


2
Avatar
Descartar
Avatar
Rihene
Mejor respuesta

Here is an example.

your_wizard.xml

<record model="ir.ui.view" id="wizard_with_step_form">

<field name="name">wizard_with_step.form</field>

<field name="model">wizard_with_step</field>

<field name="type">form</field>

<field name="arch" type="xml">

<form string="Wizard with step" version="7.0">

<field invisible="1" name="state" />

<group states="step1">

<field name="name1" />

</group>

<group states="step2">

<field name="name2" />

</group>

<footer states="step1">

<button name="action_next" string="Next" type="object" />

</footer>

<footer states="step2">

<button name="action_previous" string="Previous" type="object" />

</footer>

</form>

</field>

</record>

your_wizard.py


class wizard_with_step(osv.osv_memory):

_name = 'wizard_with_step'

_description = 'Wizard with step'

_columns = {

'name1': fields.char('Name 1',),

'name2': fields.char('Name 2',),

'state': fields.selection([('step1', 'step1'),('step2', 'step2')])

}

def action_next(self, cr, uid, ids, context=None):

#your treatment to click button next

#...

# update state to step2

self.write(cr, uid, ids, {'state': 'step2',}, context=context)

#return view

return {

'type': 'ir.actions.act_window',

'res_model': 'your_wizard',

'view_mode': 'form',

'view_type': 'form',

'res_id': this.id,

'views': [(False, 'form')],

'target': 'new',

}

def action_previous(self, cr, uid, ids, context=None):

#your treatment to click button previous

#...

# update state to step1

self.write(cr, uid, ids, {'state': 'step1',}, context=context)

#return view

return {

'type': 'ir.actions.act_window',

'res_model': 'your_wizard',

'view_mode': 'form',

'view_type': 'form',

'res_id': this.id,

'views': [(False, 'form')],

'target': 'new',

}

}

Here some useful links:

http://odoo-documents.readthedocs.org/en/latest/howtos/backend.html#wizards 

http://stackoverflow.com/questions/23005623/how-to-create-wizards-openerp

 

1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
CONFIGURACION DE CORREO PROPIO POR PRUMERA VEZ
odooV8
Avatar
0
mar 25
2034
How to remove model if not in the py files anymore
odooV8
Avatar
0
ene 25
4325
Start odoo server automatically in Ubuntu 14.04 on reboot Resuelto
odooV8
Avatar
Avatar
1
ago 23
15939
change password Resuelto
odooV8
Avatar
Avatar
1
ago 23
14483
Creating tables with %for and %endfor in email templates - Odoo is putting my loop outside the table, not inside.
odooV8
Avatar
Avatar
1
jul 23
11812
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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