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?