Search Here

Open wizard on button click in odoo

I am going to show you how to open an odoo wizard on button click. To achieve this you need to follow below steps.


How to Call Wizard from XML Button Odoo

Open wizard on button click in odoo

  1. Create form view (for wizard)
  2. Create window action (for wizard)
  3. Create a button in your XML file from where you want to open a wizard on button click.


Create form view (for wizard)


<record model="ir.ui.view" id="view_any_name_form">
<field name="name">any.name.form</field>
<field name="model">your.model</field>
<field name="groups_id"></field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="My Form">
<sheet>
<group>
<field name="field_1"/>
</group>
<group col="4" colspan="4">
<field name="field_2"/>
</group>
<group col="4" colspan="4">
<field name="field_3"/>
<field name="field_4"/>
</group>
</sheet>
<footer>
<button name="added" type="object" string="Add" class="oe_highlight"/>
or
<button special="cancel" string="Cancel"/>
</footer>
</form>
</field>
</record>

Create window action (for wizard)


<record model="ir.actions.act_window" id="action_any_name_goes_here">
<field name="name">My Action</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>

Create a button in your XML file from where you want to open a wizard on button click


<button name="%(action_any_name_goes_here)d" string="Open Wizard" class="oe_edit_only" type="action"></button>

Don,t forgot to share, keep sharing keep learning

Post a Comment

5 Comments