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
| Feature | What it gives you |
|---|---|
| Status transitions | Define which statuses exist and which moves are allowed |
| Role-based transitions | Restrict who can trigger each transition |
| Transition conditions | Validate per-object whether a transition is allowed |
| Form-based transitions | Collect user input during a transition |
| Done methods | Run custom logic after a transition completes |
| Tags | Secondary boolean flags independent of status |
| Audit trail | Every transition logged as a WorkflowTransaction record |
| Frontend UI | WorkflowStatus and WorkflowTags React components |
Install Order
appbuilder → crud → workflow
Workflow depends on both AppBuilder and CRUD — install those first.