A wizard is a finite state machine.

There is also a more practical introduction into wizards.

class trytond.wizard.Wizard(session_id)

This is the base for any wizard. It contains the engine for the finite state machine. A wizard must have some State instance attributes that the engine will use.

Class attributes are:


It contains the unique name to reference the wizard throughout the platform.


It contains the name of the starting state.


It contains the name of the ending state. If an instance method with this name exists on the wizard, it will be called on deletion of the wizard and it may return one of the client side action keywords.


Same as trytond.model.Model.__rpc__.


It contains a dictionary with state name as key and State as value.


It contains the Model class on which the wizard is executed.


It contains the Model instance on which the wizard is executed.


It contains the list of Model instances on which the wizard is executed.

Class methods are:

classmethod Wizard.__setup__()

Setup the class before adding into the trytond.pool.Pool.

classmethod Wizard.__post_setup__()

Setup the class after added into the trytond.pool.Pool.

classmethod Wizard.__register__(module_name)

Register the wizard.

classmethod Wizard.create()

Create a session for the wizard and returns a tuple containing the session id, the starting and ending state.

classmethod Wizard.delete(session_id)

Delete the session.

classmethod Wizard.execute(session_id, data, state_name)

Execute the wizard for the state. session_id is a session id. data is a dictionary with the session data to update. active_id, active_ids, active_model and action_id must be set in the context according to the records on which the wizard is run.


class trytond.wizard.State

This is the base for any wizard state.

Instance attributes are:


The name of the state.


class trytond.wizard.StateView(model_name, view, buttons)

A StateView is a state that will display a form in the client. The form is defined by the ModelView with the name model_name, the XML id in view and the buttons. The default value of the view can be set with a method on wizard having the same name as the state but starting with default_.

Instance attributes are:


The name of the ModelView.


The XML id of the form view.


The list of Button instances to display on the form.

Instance methods are:

StateView.get_view(wizard, state_name)

Returns the view definition like fields_view_get().

  • wizard is a Wizard instance

  • state_name is the name of the StateView instance

StateView.get_defaults(wizard, state_name, fields)

Return default values for the fields.

  • wizard is a Wizard instance

  • state_name is the name of the State

  • fields is the list of field names

StateView.get_buttons(wizard, state_name)

Returns button definitions of the wizard.

  • wizard is a Wizard instance

  • state_name is the name of the StateView instance


class trytond.wizard.StateTransition

A StateTransition brings the wizard to the state returned by the method having the same name as the state but starting with transition_.


class trytond.wizard.StateAction(action_id)

A StateAction is a StateTransition which let the client launch an ir.action. This action definition can be customized with a method on wizard having the same name as the state but starting with do_.

Instance attributes are:


The XML id of the ir.action.

Instance methods are:


Returns the ir.action definition.


class trytond.wizard.StateReport(report_name)

A StateReport is a StateAction which find the report action by name instead of XML id.


class trytond.wizard.Button(string, state[, icon[, default[, validate]]])

A Button is a single object containing the definition of a wizard button.

Instance attributes are:


The label display on the button.


The next state to reach if button is clicked.


The name of the icon to display on the button.


A boolean to set it as default on the form.


A boolean or None. If True, validation of the form will occur, if False it won’t. If the value is None the validation will occur only if the state of the button is not the wizard ending state.