Sequence Settings Configuration

Developer guide for the Enezaframework sequence generation. Part of the Sequence Generation series.

Table of Contents

  1. Overview
  2. Project-Level Settings
  3. Default Choices
  4. Fallback and Warnings
  5. Related Guides

Overview

Two optional settings let a project replace the framework's document-type and module choices for sequence configurations:

Setting Points to Used by
MY_PROJECT_NUMBER_SEQUENCE_DOCUMENT A document-type TextChoices class SequenceConfig.documents
MY_PROJECT_MODULES A module TextChoices class SequenceConfig.modules

Both are read by loader functions in enezaframework/models/choices.py, and both fall back to framework defaults when unset.

flowchart TD
    A["settings.py"] --> B{"MY_PROJECT_NUMBER_SEQUENCE_DOCUMENT set?"}
    B -->|Yes| C["import_string(path)"]
    B -->|No| D["NumberSequencesDocument"]
    A --> E{"MY_PROJECT_MODULES set?"}
    E -->|Yes| F["import_string(path)"]
    E -->|No| G["Modules"]

Project-Level Settings

python
# settings.py

# Custom document types for sequence generation
MY_PROJECT_NUMBER_SEQUENCE_DOCUMENT = 'myproject.choices.ProjectDocumentTypes'

# Custom module categories
MY_PROJECT_MODULES = 'myproject.choices.ProjectModules'

The dotted path must point at the class (an models.TextChoices subclass), not a module or an instance. See Sequence Document & Module Choices for the class definitions.

Do not use YOUR_PACKAGE_* names — the framework reads exactly MY_PROJECT_NUMBER_SEQUENCE_DOCUMENT and MY_PROJECT_MODULES.


Default Choices

When a setting is not provided, enezaframework/models/choices.py supplies the defaults.

Default document types (NumberSequencesDocument) include, among others:

  • Journals and banking: BANK, BANK_JOURNAL, GENERAL_JOURNAL, CUSTOMER_JOURNAL.
  • Sales and purchasing: CUSTOMER, VENDOR, INVOICE, PURCHASE_ORDER, SALES_ORDER, DELIVERY_NOTE, GOODS_RECEIVED_NOTE.
  • Assets, payroll, and reporting: FIXED_ASSETS, EMPLOYEE, EXPENSE, AUDIT_REPORT.

Default modules (Modules) include:

  • GENERAL_LEDGER, ACCOUNTS_PAYABLE, ACCOUNTS_RECEIVABLE, CUSTOMER_ENGAGEMENT.
  • FIXED_ASSETS, INVENTORY_MANAGEMENT, PAYROLL, CASH_MANAGEMENT.
  • TAX_MANAGEMENT, FINANCIAL_REPORTING, PROCUREMENT_MANAGEMENT, and more.

Using the defaults requires no settings at all — just reference the default choice values in your models.


Fallback and Warnings

The loaders (get_number_sequences_choices() at models/choices.py:70-90, get_modules_choices() at :122-149) warn and fall back when the configured path cannot be imported:

text
WARNING: Could not import myapp.choices.ProjectDocumentTypes: No module named 'myapp.choices'. Using default choices.

Because the fallback is a warning rather than an exception, a misconfigured path surfaces as the wrong set of choices in admin. If admin shows framework defaults when you expected project choices, check the dotted path first.

The choices are resolved when SequenceConfig is imported (the fields call .choices at class definition), so a settings change requires a process restart to take effect.