To enhance the user experience, Odoo uses wizards to create interactive sessions. This type of interactive session is very beneficial for any business. The transient Model and abstract model can create a wizard. But Transient Model is mainly used for creating wizards in Odoo. This gives all the features of the Model except A transient model stores data temporarily and periodically deletes it.
Wizards extend the class Transient Model instead of models and below is the specification
- Eventually, wizard data are automatically removed from the database; they are not permanent.
- Through many2one fields, wizard records may refer to regular data or wizard data, but regular data cannot refer to wizard data.
- Wizard data is accessible to all users
First, we need to create a directory named wizard on your module, then inside this module, create a python file for a wizard and create a transient model class as shown below.
Next, we need to create a view for this wizard. Wizards are always open as ir. Actions.act_window data. Here we can start the wizard action by using the menu item we can also use the button action. So, here when we click the menu item this will open a wizard, so we can create a menu item.
Next, we can add actions for this menu,
res_model: on which model this action will be performed
we want to give the ‘id’ given in this action to ‘action’ in the menu item.
Here we give view_mode as form, so we need to create a view for this wizard. The following code can be used to accomplish that.
On the view, we can specify the model, and inside the form tag, we can give whatever field we need to show in the wizard.
Also, the default footer will be ok, if we need to add any button, we can add it in the footer tag. Inside the form tag and after the closing group tag.
Here we need to define the action_done button in the py file. This is how we can create a wizard in Odoo 16.