Wizard#
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
Stateinstance attributes that the engine uses.
Class attributes are:
- Wizard.__name__#
The unique name to reference the wizard throughout the platform.
- Wizard.start_state#
The name of the starting state.
- Wizard.end_state#
The name of the ending state.
If an instance method with this name exists on the wizard, it is called on deletion of the wizard and it may return one of the client side action keywords.
- Wizard.__rpc__#
Same as
trytond.model.Model.__rpc__.
Class methods are:
- 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_idis a session id.datais a dictionary with the session data to update.active_id,active_ids,active_modelandaction_idmust be set in the context according to the records on which the wizard is run.
State#
- class trytond.wizard.State#
The base for any wizard state.
Instance attributes are:
- State.name#
The name of the state.
StateView#
- class trytond.wizard.StateView(model_name, view, buttons)#
A
StateViewis a state that will display a form in the client.The form is defined by the
ModelViewwith the namemodel_name, theXMLid inviewand thebuttons. The default values of the view can be set with a method on wizard having the same name as the state but starting withdefault_. The values of the view can be also set with a method on wizard having the same name as the state but starting withvalue_.Note
The difference between default values and values is that the client calls
on_change()andon_change_with()for the default values.
Instance attributes are:
- StateView.view#
The XML id of the form view.
Instance methods are:
- StateView.get_view(wizard, state_name)#
Return the view definition like
fields_view_get().wizardis aWizardinstance.state_nameis the name of theStateViewinstance.
- StateView.get_defaults(wizard, state_name, fields)#
Return default values for the fields.
wizardis aWizardinstance.state_nameis the name of theState.fieldsis the list of field names.
StateTransition#
- class trytond.wizard.StateTransition#
A
StateTransitionbrings the wizard to thestatereturned by the method having the same name as the state but starting withtransition_.
StateAction#
- class trytond.wizard.StateAction(action_id)#
A
StateTransitionwhich lets the client launch an 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:
Instance methods are:
StateReport#
- class trytond.wizard.StateReport(report_name)#
A
StateActionwhich find the report action by name instead of XML id.