Sequence Admin Setup
Developer guide for the Enezaframework sequence generation. Part of the Sequence Generation series.
Table of Contents
- Overview
- Creating a Configuration
- Format Settings
- Entity Settings
- Managing Configurations
- Example Configurations
- Related Guides
Overview
A sequence only generates for a document type that has an active SequenceConfig. The admin is the normal place to create and edit those records. This page covers the fields you set and the constraints to respect.
flowchart LR
A["Admin: Number Sequences"] --> B["Choose Document + Module"]
B --> C["Set prefix, delimiter, length"]
C --> D["Set active = True"]
D --> E["Model.save() finds the config"]Creating a Configuration
- Navigate to System Administrator → Number Sequences.
- Click Create New (or edit an existing row).
- Fill in the fields below.
Basic settings:
| Field | Guidance |
|---|---|
| Document | The document type the model uses as document_name. |
| Module | The module category for organization. |
| Active | Check to make this the config generate_sequence() uses. |
Format settings:
| Field | Guidance |
|---|---|
| Prefix | Alphanumeric prefix (CUST, INV, PO). |
| Delimiter | One character between prefix and number (-, _, /). |
| Number Length | Number of digits (4 → 0001, 6 → 000001). |
Next number:
| Field | Guidance |
|---|---|
nextnumber |
The first number to hand out. Start at 1 for new data, or higher to continue an existing series. |
Format Settings
The generated value is:
prefix + delimiter + zero_padded(nextnumber, number_length)
flowchart LR
P["prefix: CUST"] --> V
D["delimiter: -"] --> V
N["nextnumber: 1, length: 4"] --> V
V["CUST-0001"]number_lengthpads with leading zeros; a number wider than the configured length is not truncated.- Changing the format later affects only numbers generated after the change.
Entity Settings
entity scopes a configuration to a company in multi-tenant deployments. Leave it blank to apply the configuration across entities.
generate_sequence()filters bydocumentsandactiveonly — not byentity. It returns the first matching active config. If you rely on per-entity sequences, makeentitypart of your lookup logic and ensure the query is scoped consistently.
Managing Configurations
| Task | How |
|---|---|
| Change the format | Update an existing config, or deactivate it and create a new one. |
| Keep history | Limited by the constraint — see below. |
| Reset numbering | Set nextnumber back (reuses numbers; use with care). |
Constraint:
SequenceConfighasUniqueConstraint(fields=['documents', 'active'])(models/enezasequence.py:28-31). For a given document type, at most one row can beactive=Trueand at most one row can beactive=False. You therefore cannot keep multiple inactive configurations as an archive for the same document. See Sequence Configuration Model.
Example Configurations
| Document | Prefix | Delimiter | Length | Format example | Notes |
|---|---|---|---|---|---|
| Customer | CUST | - |
4 | CUST-0001 |
Start at 1. |
| Invoice | INV | - |
5 | INV-00001 |
Start at 1001 to continue an existing series. |
| Purchase Order | PO | / |
3 | PO/001 |
Short format. |
| Employee | EMP | - |
4 | EMP-0001 |
HR module. |