Building a Wizard in Odoo

A wizard is an interactive step, often to gather input before doing something. How a developer builds one.

Sometimes an action needs input from the user before it can be carried out. A wizard gathers that input. This piece is about building a wizard in Odoo.

What a wizard is

A wizard, in Odoo, is an interactive step, usually a dialog, that gathers input from the user before something is done. There are actions that cannot just be carried out, because they need the user to provide something first, a choice, some values, the input the action needs. A wizard is the means of gathering that: it presents the user with a step to provide the input, and then, with the input gathered, the action is carried out. The wizard is the interactive input-gathering before the action.

Why wizards are used

Wizards are used because some actions genuinely need user input that has to be gathered interactively. The action cannot simply happen; the user has to provide something for it first. A wizard handles that: rather than the action failing for want of input, or the input being gathered some awkward way, the wizard cleanly presents the user with the step to provide what is needed, gathers it, and the action proceeds with it. Wizards are how Odoo handles the common situation of an action that needs interactive input.

How a wizard is built

A developer builds a wizard with the pieces that make it work. A wizard has, in effect, its own model, but a particular kind: a wizard's model holds the input being gathered, and it is transient, the wizard's data is for the moment of the wizard, not a permanent record. The wizard has a view, the form the user sees and provides the input into. And it has the logic for what happens when the user, having provided the input, proceeds, the action that is carried out with the gathered input. Building a wizard is building those pieces: the transient model for the input, the view for gathering it, and the logic of the action.

Why a wizard's model is transient

An important point in building a wizard: the wizard's model is transient, not a permanent record. This is genuinely right, because the input a wizard gathers is for the moment, it is what the user is providing for this action, now, and it is not something that should become a lasting record in the system. A wizard's transient model holds the input just for the wizard's use, and it is not kept as a permanent record afterward. Building a wizard correctly means understanding that its model is this transient kind, suited to the momentary input it gathers.

Build it the Odoo way

Building a wizard, like all Odoo development, should be done the Odoo way: wizards have an established way they are built in Odoo, the transient model, the view, the logic, and a wizard built that way works properly within the framework. A developer building a wizard should do it within Odoo's conventions, the established way, working with the framework.

The takeaway

Building a wizard in Odoo creates an interactive step, usually a dialog, that gathers input from the user before an action is carried out. Wizards are used because some actions genuinely need interactive user input first. A developer builds a wizard with a transient model, which holds the gathered input for the moment rather than as a permanent record, a view for gathering the input, and the logic of the action carried out with it. A wizard's model is rightly transient, suited to momentary input. Build a wizard the Odoo way. For how we approach Odoo, see our ERP practice.

All posts

Got a Topic Worth Posting?

Suggest a Topic

If a question keeps coming up in your operations, it might be worth its own post.