Create Wizards in Odoo 17

ADARSH
January 8, 2024
wizard-in-odoo-17

Wizards are extremely useful in creating a positive user experience. In all businesses, interactive sessions are essential. In Odoo 17, wizards provide interactive sessions to improve the user experience.

Wizards can be created using transient or abstract models. Except for data storage, this provides model class functionality. In transient and abstract models, database persistence is permanent. They are given database tables, and it kept the records in these databases until they are explicitly removed.

An Odoo wizard, rather than a model, is a model that extends the class Transient Model. In the following ways, the class Transient model extends models and reuses all of its existing mechanisms:

1. Odoo Wizard data is not permanent; it is deleted from the database after a set period.

2. All users have full access to the wizard data.

3. Wizard records can use many2one fields to refer to either regular or wizard data, but regular data cannot use many2one fields to refer to wizard data.

To begin, we must create a transient model class for the wizard. In your module, create a wizard directory as well.

create-wizards-in-odoo

Remember to include the model in the security file and grant the necessary permissions.

We must then create a view for that wizard to open. Wizards should be opened as it. actions—act_window data at all times. The wizard action can be initiated by a menu item or button action defined in Python or XML code.

We can create a button action that will launch a wizard. To accomplish this, we can use the code below.

wizard-in-odoo17

This XML code adds a message-sending button to the Odoo project. task form view. The button is added to the form view’s existing button_box section.

Name the function’s name.

type=”object”: Denotes that the button performs an Odoo object action.

odoo-object-action

After that, we can give the Button a function.

erp-button-function

type: Specifies the type of action, which is opening a window.

name: Sets the name (title) of the window.

res_model: Specifies the model associated with the window.

target: Indicates that the window should be opened in a new tab or window.

view_mode: Specifies the view mode for the window.

view_type: Specifies the type of view.

context: Passes a context to the new window.

Next, we need to create a view to display the wizard. We can apply the following code to do this.

On the view, we can simply provide the name model as well as the fields that show on the view. The view is generally represented by the model ir.ui.view.

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *