Skip to main content

Workflow Package

The Workflow package manages the lifecycle of records through controlled status transitions. Instead of a plain status field, you define a WorkflowBase class that controls which statuses exist, how records move between them, who can trigger each transition, and what logic runs after one.

When to Use Workflow

Use the Workflow package whenever a record has a lifecycle — states it moves through with rules about who can move it and when:

  • Order: Draft → Submitted → Approved → Shipped → Delivered
  • Patient case: Open → In Progress → Resolved → Closed
  • Leave request: Draft → Pending → Approved / Rejected

How It Fits Together

Model (models.py)
↑ status managed by workflow

WorkflowBase (workflow.py)
- statuses and initial status in Meta
- status_transitions list
- condition methods ← can this transition happen?
- done methods ← what runs after it does?

BaseCrudView (views.py)
- workflow = YourWorkflow ← attach here

Key Features

FeatureWhat it gives you
Status transitionsDefine which statuses exist and which moves are allowed
Role-based transitionsRestrict who can trigger each transition
Transition conditionsValidate per-object whether a transition is allowed
Form-based transitionsCollect user input during a transition
Done methodsRun custom logic after a transition completes
TagsSecondary boolean flags independent of status
Audit trailEvery transition logged as a WorkflowTransaction record
Frontend UIWorkflowStatus and WorkflowTags React components

Install Order

appbuilder → crud → workflow

Workflow depends on both AppBuilder and CRUD — install those first.