Skip to main content

Executing Transitions

When executing transitions within your workflow, it's crucial to define transition conditions and processing methods to ensure smooth workflow operations. Transition conditions determine when a transition can be executed based on various factors such as object state or any custom logic like user permissions. Processing methods handle the execution of transitions, performing any necessary actions or processing after the transition is executed. By carefully defining transition conditions and processing methods, you can maintain consistency and reliability in your workflow system.

Transition Conditions

Transition conditions are defined as methods within the Workflow class, providing granular control over when transitions can be executed.

Method Signature

def <transition_name>_condition(self, request, object_instance, **kwargs):

Parameters

  • self: Instance of the Workflow class.
  • request: HttpRequest object representing the user's request.
  • object_instance: The instance of the object on which the transition is being executed.
  • kwargs: Additional keyword arguments.

Return Value

  • bool: True if the transition can be executed, False otherwise.

Processing Methods

Processing methods, named <transition_name>_done, handle the execution of transitions and any associated actions or processing.

Method Signature

def inactivate_done(self, request, object_instance, transaction_obj):

Parameters

  • self: Instance of the Workflow class.
  • request: HttpRequest object representing the user's request.
  • object_instance: The instance of the object on which the transition is being executed.
  • transaction_obj: Instance of WorkflowTransaction (workflow.base.models) model.

These methods are responsible for actions such as updating database records or triggering notifications, ensuring that the workflow proceeds smoothly after a transition is completed.