This question has been flagged

This is my wizard code:

    def action_next1(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': 'bsi_production_order',

            'view_mode': 'form',

            'view_type': 'form',

            'res_id': this.id,

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

            'target': 'new',

             }

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

      #your treatment to click button next

      #...

      # update state to step2

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

      #return view

      return {

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

            'res_model': 'bsi_production_order',

            'view_mode': 'form',

            'view_type': 'form',

            'res_id': this.id,

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

            'target': 'new',

             }

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

      #your treatment to click button next

      #...

      # update state to step2

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

      #return view

      return {

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

            'res_model': 'bsi_production_order',

            'view_mode': 'form',

            'view_type': 'form',

            'res_id': this.id,

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

            'target': 'new',

             }

    def action_previous1(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': 'bsi_production_order',

            'view_mode': 'form',

            'view_type': 'form',

            'res_id': this.id,

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

            'target': 'new',

             }

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

      #your treatment to click button previous

      #...

      # update state to step1

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

      #return view

      return {

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

            'res_model': 'bsi_production_order',

            'view_mode': 'form',

            'view_type': 'form',

            'res_id': this.id,

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

            'target': 'new',

             }

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

      #your treatment to click button previous

      #...

      # update state to step1

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

      #return view

      return {

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

            'res_model': 'bsi_production_order',

            'view_mode': 'form',

            'view_type': 'form',

            'res_id': this.id,

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

            'target': 'new',

             }

And this is the respective view:

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

            <field name="name">bsi.production.order.form</field>

            <field name="model">bsi.production.order</field>

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

                <form string="Production Order">

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

                    <group states="step1">

                      <group>

                        <group>

                          <field name="date_production"/>

                          <field name="product_id"/>

                          <field name="qty_available"/>

                          <field name="isbn1" attrs="{'invisible': [('type_prod', '!=', 'direct')]}" />

                          <field name="isbn2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="isbn3" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="isbn4" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="isbn5" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="isbn6" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                        </group>

                        <group>

                          <field name="type_prod"/>

                          <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}" />

                          <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                          <field name="print_order2" attrs="{'invisible': [('type_prod', '!=', 'direct')]}"/>

                        </group>

                    </group>

                  </group>

                    <group states="step2">

                        <group string="Book Block">

                                <field name="name_block"/>

                                <!--<field name="description"/>-->

                                <field name="category"/>

                                <field name="language"/>

                                <field name="edition"/>

                                <field name="size"/>

                                <field name="book_block_textp"/>

                                <field name="n_pages_one_color"/>

                                <field name="two_color"/>

                                <field name="four_color"/>

                                <field name="total"/>

                                <field name="text_print_code"/>

                                <field name="book_block_adpaper"/>

                                <field name="adnl_n_pages_one_color"/>

                                <field name="adnl_two_color"/>

                                <field name="adnl_third_color"/>

                                <field name="adnl_four_color"/>

                                <field name="adnl_total"/>

                                <field name="adnl_text_print_code"/>

                                <field name="book_block_txtep"/>

                                <field name="n_of_end_pages"/>

                        </group>

                        <group string="Book Size">

                                <field name="name_size"/>

                                <field name="description_size"/>

                                <field name="forme_size"/>

                                <field name="plate_size"/>

                        </group>

                    </group>

                    <group states="step3">

                        <group string="Book Edition">

                                <field name="name_edition"/>

                        </group>

                        <group string="Book Binding">

                                <field name="name_binding"/>

                        </group>

                        <group string="Cut Off">

                                <field name="name_cut"/>

                                <field name="description_cut"/>

                                <field name="cutoff_size"/>

                        </group>

                        <group string="Paper Master">

                                <field name="name_papermaster"/>

                                <field name="description_papermaster"/>

                                <field name="paper_type"/>

                                <field name="uom_papermaster"/>

                                <field name="gsm_papermaster"/>

                                <field name="std_cost_rate"/>

                                <field name="qty_in_kgs"/>

                                <field name="size_width"/>

                                <field name="size_height"/>

                        </group>

                    </group>

                    <group states="step4">

                        <group string="End Paper">

                                <field name="name_end_paper"/>

                                <field name="category_end_paper"/>

                                <field name="size_end_paper"/>

                        </group>

                        <group string="Printing Code">

                                <field name="description_code"/>

                                <field name="size_code"/>

                        </group>

                        <group string="Book Edge">

                                <field name="name_book_edge"/>

                        </group>

                        <group string="Job Rate">

                                <field name="name_jobrate"/>

                                <field name="binding"/>

                                <field name="size_binding_job_rate"/>

                                <field name="bind_variety"/>

                                <field name="rates"/>

                                <field name="addl_rate"/>

                                <field name="uptoforme"/>

                        </group>

                    </group>

          <footer states="step1">

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

            <button string="Cancel" class="oe_link" special="cancel"/>

          </footer>

          <footer states="step2">

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

            <button string="Cancel" class="oe_link" special="cancel"/>

          </footer>

          <footer states="step2">

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

            <button string="Cancel" class="oe_link" special="cancel"/>

          </footer>

          <footer states="step3">

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

            <button string="Cancel" class="oe_link" special="cancel"/>

          </footer>

          <footer states="step3">

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

            <button string="Cancel" class="oe_link" special="cancel"/>

          </footer>

          <footer states="step4">

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

            <button string="Cancel" class="oe_link" special="cancel"/>

          </footer>

            </form>

            </field>

        </record>

Now, if I want to open this wizard view, it just shows an empty white form.

I wonder if this is because of this line on wizard `'views': [(False, 'form')],` I mean, before I had a wizard which just opened the original form, and that equivalent line was like this `'view_id': self.env.ref('mrp_worksheet_contract.view_prod_order_form').id,` But then again, I'm not looking forward to open the original form, just most of the fields of it in a step by step fashion.

Any ideas?

Avatar
Discard

I suspect it is because of the views: [(False, 'form')]. I have myself implemented a multi-step wizard and have used the 'view_id': ... version.

This will not open the original form, it will simply tell Odoo which XML record to use to generate the view. Which form will be opened (or more precisely: how it will look) depends on the state of your wizard, which you set in each return.

Also, the python code you have shown contains a lot of duplication. I would suggest to create a helper function for returning the view for the next step:

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

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

return {

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

'res_model': 'bsi_production_order',

'view_mode': 'form',

'view_type': 'form',

'res_id': this.id,

'view_id': self.env.ref('mrp_worksheet_contract.view_prod_order_form').id,

'target': 'new',

}