Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

4

How to create a wizard with steps ?

By
Antanas
on 6/4/13, 9:14 AM 15,768 views

Say there is such a problem: A user opens a wizard, the wizard checks for a condition, associated with a user, and if condition is "foo", the wizard procedes, if condition is "bar", another action must be taken- another wizard must be opened, and previous one must be closed. How can this be implemented in OpenERP?

14

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 6/4/13, 9:28 AM

Hi,

you can use field state in the same wizard without create a new.

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',
             }


  }

Thank you for this clear explanation.

Antanas
on 6/7/13, 4:45 AM

Hy, I read somewhere that states are depreciated for wizard. Is it true?

Mind & Go, Mind And Go
on 6/9/14, 2:22 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 6/4/13, 9:14 AM
Seen: 15768 times
Last updated: 3/1/16, 9:12 AM