I'm trying to create a wizard.
This is the view code:
<?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_servizio"
string="Crea Servizio"/>
<button type="object"
name="crea_attivita"
string="Crea 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">Selezione 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>
<!-- Action to open To-do Task list -->
<act_window id="action_mymodule_wizard" name="Attività / Servizio" res_model="mymodule.wizard" view_mode="tree,form" />
<!-- Menu item to open To-do Task list -->
<menuitem id="menu_mymodule_wizard" name="Menu mymodule Wizard" parent="mail.mail_feeds" sequence="40" action="action_mymodule_wizard" />
</data>
</openerp>
and this is the py file:
# -*- encoding: utf-8 -*-
from openerp import models, api
class wizard(models.TransientModel):
_name = 'mymodule.wizard'
_description = "Wizard per la scelta dell'azione"
@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',
}
def crea_servizio(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'mymodule.tbl_servizio',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
}
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)
class mymodule_servizio(models.Model):
_name = 'mymodule.tbl_servizio'
_description = 'Tabella Servizio'
scode_servizio = fields.Char('Code', size=1, required=True)
sdescrizione = fields.Text('Descrizione', required=True)
I have two problems.
1) When I click on "Crea servizio" in the wizard, I get this error:
Traceback (most recent call last):
File "/home/openerp/openerp/http.py", line 530, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/openerp/openerp/http.py", line 567, in dispatch
result = self._call_function(**self.params)
File "/home/openerp/openerp/http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/openerp/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/home/openerp/openerp/http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "/home/openerp/openerp/http.py", line 796, in __call__
return self.method(*args, **kw)
File "/home/openerp/openerp/http.py", line 396, in response_wrap
response = f(*args, **kw)
File "/home/openerp/openerp/addons/web/controllers/main.py", line 953, in call_button
action = self._call_kw(model, method, args, {})
File "/home/openerp/openerp/addons/web/controllers/main.py", line 941, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
TypeError: crea_servizio() takes exactly 1 argument (5 given)
Instead, everything is ok with the other button (Crea Attivita).
2) I'm not able to make an action when I click on "Crea Attivita". I see the module 'mymodule' in the pop up, but I don't know I I have to do for writing in the db.
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 Attivita</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>
<record id="view_mymodule_servizio" model="ir.ui.view">
<field name="name">mymodule Servizio</field>
<field name="model">mymodule.tbl_servizio</field>
<field name="arch" type="xml">
<form string="mymodule Servizio">
<sheet>
<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 name="left">
<field name="scode_servizio"/>
<field name="sdescrizione"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<!-- Action to open To-do Task list -->
<act_window id="action_mymodule_attivita" name="Attivita" res_model="mymodule.tbl_attivita" view_mode="tree,form" />
<act_window id="action_mymodule_servizio" name="Servizio" res_model="mymodule.tbl_servizio" view_mode="tree,form" />
<!-- Menu item to open To-do Task list -->
<menuitem id="menu_mymodule_attivita" name="Menu mymodule Attivita" parent="mail.mail_feeds" sequence="20" action="action_mymodule_attivita" />
<menuitem id="menu_mymodule_servizio" name="Menu mymodule Servizio" parent="mail.mail_feeds" sequence="30" action="action_mymodule_servizio" />
</data>
</openerp>
Could you help me, please?