NamingCounter
Counter storage for naming series.
Stores the current counter value for each prefix, enabling
persistent and queryable counter management.
Example:
# Counter for INV-2026- prefix
counter = NamingCounter(prefix="INV-2026-", current=42)
# Next invoice will be INV-2026-0043
Note:
Uses optimistic updates - no SELECT FOR UPDATE needed.
On conflict, retry with incremented value.
Source: naming_counter.py
Fields
| Field | Type | Required | Description | Validators |
|---|---|---|---|---|
| prefix | str | Naming series prefix | - | |
| current | int | Current counter value | - |
Configuration
| Setting | Value |
|---|---|
| Submittable | False |
| Track Changes | True |
Controller
Controller hooks are implemented in *_controller.py files.
Available lifecycle hooks:
validate()- Called before save, raise exceptions for validation errorsbefore_insert()- Called before inserting a new documentafter_insert()- Called after successfully insertingbefore_save()- Called before saving (insert or update)after_save()- Called after savingbefore_delete()- Called before deletingafter_delete()- Called after deleting