How to create a Wizard in odoo14

CREATING WIZARDS IN ODOO 14

Wizards are used to having interactive sessions with the dialogue boxes in Odoo.Mainly wizard is available in Transient model.

Transient models:

It’s based on the model TransientModel class. Moreover, the data stored in the database is temporary in this class which is periodically cleared data from the database table.

This blog will provide insight on How to create  a wizard in odoo 14

  • We have to create a new class in models  directory python file

eg: class <classname>(models.Model):  and fields.

<field name>=fields.<type>(string='<label name>’)

practical case:

class OdooWizard(models.TransientModel):

_name=’odoo.wizard’

name=fields.Char(“Name)

dob=fields.Char(“DOB”)

  • Now you need to add corresponding xml file under views,

eg: <record id=”record_id” model=”ir.ui.view”>
              <field name=”name”>you can mension any name</field>
              <field name=”model”> your model name</field>
              <field name=”arch” type=”xml”>
              <form string=”any name”>
              <group>
                <field name>=fields.<type>(string='<label name>’)
               </group>
        </form>
   </field>
</record>

  • This code is used to display the fields

 <record id=”record id ” model=”ir.actions.act_window”>

           <field name=”name”>any name</field>

           <field name=”type” >ir.actions.act_window</field>

           <field name=”res_model”>model.name</field>

           <field name=”view_model”>form</field>

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

</record>

  • This code for showing the popup

In practical case:

<record id=”create_new_form” model=”ir.ui.view”>

             <field name=”name”>New Wizard</field>

            <field name=”model”>odoo.wizard</field>

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

            <form string=”Wizard Details”>

            <group>

                 <field name=”name”/>

                 <field name=”dob”/>

             </group>

       </form>

        </field>

</record>

 

<record id="action_new_wizard" model="ir.actions.act_window">
        <field name="name">Sample Wizard</field>
        <field name="res_model">odoo.wizard</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_mode">form</field>
        <field name="target">new</field>
    </record>
            <menuitem name ="new_wizard_menu"
              id ="odoo_wizard_id"
              action="action_new_wizard"/>

 

  • action record id you need to give  in menu action then only the action will work
  • Do not forget to give these xml files  in __manifest__.py
  • Then run the module

The Print will be like this

 

To know more about us

 

 

 

Leave a Reply

Your email address will not be published.