Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Problem with a wizard

Subscribe

Get notified when there's activity on this post

This question has been flagged
3 Replies
7252 Views
Avatar
Uillino

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?

0
Avatar
Discard
Avatar
Tangaraj
Best Answer

Always create transiant model for wizard.

class wiz_form(models.TransientModel):

_name = 'wiz'

tname=fields.Char('Name 1')

pname= fields.Char('Name 2')

state = fields.Selection([('step1', 'step1'),('step2', 'step2')])


@api.multi

def action_next(self):

 return True


@api.multi

def action_previous(self):

return True

Proceed your xml part like this.


<?xml version='1.0' encoding='UTF-8'?>

<openerp>

<data>

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

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

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

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

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

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

<sheet>

<group>

<field name="tname" />

<field name="pname" />

<field name="state" />

</group>

</sheet>

<footer>

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

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

class="oe_highlight" />

</footer>

</form>

</field>

</record>

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

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

<field name="res_model">wiz</field>

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

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

</record>

</data>

</openerp>

Dont forget to create init file for wizard..

and dnt forget to import in main init.pls try it for your case and put it in openerp data[''wizard/wiz.xml'] top most end

1
Avatar
Discard
Uillino
Author

Thank you for your help. I need some explanation. First of all, I haven't understood if I have to raplace my wizard.py and wizard_view.xml files with yours. Then, What I have to set as "step1" and "step2"?

Avatar
PY
Best Answer

1. Put @api.multi before your method.

2. Try to add:

"view_id": self.env.ref("mymodule.view_mymodule_attivita"),

to the dictionnary returned by the crea_attivita method.

1
Avatar
Discard
Avatar
Uillino
Author Best Answer

Thank you!

Any advice about the other problem?

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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