Data Files
Data files load initial records when a module is installed.
File format: YAML is the convention. Every shipped module writes its data files as
.yaml(the loader also accepts.json/.yml). The examples below are shown in YAML; the record shape (data_type,identifier, fields, command arrays) is identical in both formats.
File Location
Section titled “File Location”Place data files (.yaml) in the appropriate directories — no manifest data: key is
needed; the loader auto-discovers every .yaml/.yml/.json file (except those starting
with _) under views/, data/, security/, and templates/ (plus demo/ in demo mode):
modules/your_module/├── views/│ ├── views.yaml # UI views (UiView)│ ├── actions.yaml # Window actions (WindowAction)│ └── menus.yaml # Menus (UiMenu)├── data/│ ├── stages.yaml # Seed data (user-customizable)│ └── categories.yaml # Reference data├── security/│ └── security.yaml # Groups and permissions└── templates/ ├── section_templates.yaml # Template definitions ├── hero.jinja # Jinja template files └── report_layout.jinja # Report templatesFolder Purposes
Section titled “Folder Purposes”| Folder | Purpose | Record Types |
|---|---|---|
views/ | UI definitions | UiView, WindowAction, UiMenu |
data/ | Seed/reference data | Any model (stages, currencies, categories) |
security/ | Access control | Group, ModelAccess, RecordRule |
templates/ | All templates | WebsiteSectionTemplate, ReportLayout, WebPage |
demo/ | Sample records, loaded only on a demo database | Any model |
Files starting with _ are ignored (e.g., _draft.json).
Demo data sends nothing
Section titled “Demo data sends nothing”Demo records go through the same lifecycle as real ones, so loading them can queue real
messages: a demo ticket’s reply, a demo subscription’s failed-payment notice, a signature
request your post_install hook sends to exercise its own flow. On a demo database, every
outbound message queued while a module is installed or updated — by its data files or by its
pre_data/post_install/post_update hooks — is settled as Withheld with the reason
Demo data: never sent. The records keep their history (a sent request still shows as sent),
but nothing is delivered, now or by any copy of the database later.
You do not need to guard your seeding code for this. Write the demo the way a user would use the feature. Messages queued after the install — by someone using the database — are delivered normally.
Structure
Section titled “Structure”Data files are arrays of record definitions (a YAML list, or a JSON array):
- data_type: ModelName identifier: unique_identifier field1: value1 field2: value2Record Fields
Section titled “Record Fields”Required Fields
Section titled “Required Fields”| Field | Description |
|---|---|
data_type | Model class name |
identifier | Unique identifier for updates |
apply_once Flag
Section titled “apply_once Flag”Controls whether records are updated on module update:
- data_type: CrmStage identifier: crm_stage_new name: New sequence: 1 apply_once: true| Value | Behavior |
|---|---|
true | Only create if not exists (preserves user customizations) |
false (default) | Always create/overwrite on update |
When to use apply_once: true:
- Seed data users may customize (stages, categories, currencies, payment terms)
- Reference data with user-editable fields
When to use apply_once: false (or omit):
- System records that must stay in sync (cron jobs)
- UI definitions (views, actions, menus) - these are managed by the module system
- Security records (groups, model access) - should always match code
For ordinary data records the loader applies partial updates: on re-import it only
writes the fields your record actually lists, and leaves any column you didn’t mention
untouched. So to clear a field on an already-stored data record, set it to null
explicitly; simply deleting the line leaves the existing value in place.
Managed records are the exception — UiView, WindowAction, UiMenu, Group,
ModelAccess and RecordRule. For these the owning module’s declaration is the record:
on the owner’s re-import, a field it no longer declares is reset to its default (so
deleting a menu’s parent: line does promote it to top level). Collections (groups,
views) are not reset, since their commands contribute rather than replace.
File References
Section titled “File References”Template files can be referenced from JSON by filename. The loader auto-detects file references based on known template extensions:
- data_type: WebsiteSectionTemplate identifier: hero_centered template: hero_centered.jinjaSupported extensions: .jinja, .jinja2, .html, .xml, .txt, .md, .css, .js
How it works:
- String fields with supported template extensions
- That don’t start with
http://,https://, or/ - Are treated as file references relative to the JSON file
- The file content is loaded into the field
Examples:
template: hero.jinja # Loads ./hero.jinjacontent: ../templates/block.jinja # Loads from parent/templates/layout: layouts/standard.jinja # Loads from ./layouts/Relative Dates (@today / @now)
Section titled “Relative Dates (@today / @now)”Date and Datetime field values may be written as a relative-date token instead of a
fixed calendar date. The loader resolves it at import time against the install date, so seed
and demo data stays anchored to “now” and never goes stale — a database installed today and
one installed a year from now both render a live, non-flat trend in date-grouped reports
instead of every record landing on install-day.
- data_type: SaleOrder identifier: demo_order_acme_001 date: "@today-90d" # 90 days before install validity_date: "@today+7d" # 7 days after installGrammar: an anchor (@today for a date, @now for a datetime) followed by zero or more
signed offsets <+|->N<unit>:
| Unit | Meaning | Example |
|---|---|---|
d | days | @today-45d |
w | weeks | @today-2w |
mo | months | @today-3mo |
y | years | @today-1y+15d |
h | hours (@now only) | @now-2h |
min | minutes (@now only) | @now-30min |
There is no bare m: it could mean minutes or months, and either reading would load without
complaint. A token using it is refused at import with a message naming both spellings.
@today yields a calendar date; @now yields a UTC timestamp. On a Datetime field,
@today lands at midnight UTC so date-grouped reports bucket cleanly. A malformed token
(e.g. @today-45) fails loudly at import rather than silently resolving to today. A value
that doesn’t start with @ is treated as a literal date exactly as before.
Note: audit fields like
created_dateare stamped by the ORM on create and can’t be set from a data file — back-date those in apost_installhook if a report keys on them.
Record References by Identifier (@ref:)
Section titled “Record References by Identifier (@ref:)”A few models point at “any record” with a model name plus an Integer id rather than a
relation — an approval request’s record, for example. A data file cannot know that id, so
write the record’s identifier instead:
- data_type: ApprovalRequest identifier: demo_approval_req_pending model: Contact record_id: "@ref:Contact:demo_vendor_ironbark_supply"@ref:<Model>:<identifier> resolves at import to that record’s id (an archived record
counts). An identifier that no record carries fails the import, naming the file and field.
For an ordinary relation field use the identifier directly, as everywhere else.
File Order and Dependencies
Section titled “File Order and Dependencies”Within one module, file order is handled for you. Files are imported in a fixed,
alphabetical order per directory, and a reference to an identifier that hasn’t been
imported yet pulls in the file that declares it first — so menus.yaml referencing an
action declared in actions.yaml resolves regardless of which file is read first. A
reference that no file in the module (or its dependency modules) declares still fails at
import, naming the file, field and identifier.
Use depends when you need to order imports for a reason the loader can’t infer from a
reference — most often a file in another directory whose records must exist first:
- data_type: WindowAction depends: - product_views identifier: products_action name: ProductsKey points:
- The value is a list of file names without extension (the loader resolves
.yaml/.yml/.json) - Files listed in
dependsare imported before the current record is processed - Records in other modules are available because those modules install first — list the
module in the manifest’s
dependencies, not independs
Cross-Directory Dependencies
Section titled “Cross-Directory Dependencies”Automatic resolution spans a module’s views/, data/, security/ and templates/
directories, so a menu in views/ referencing a group declared in security/ needs no
depends. The one exception is demo/: it is imported only on a demo database, so a file
outside demo/ never pulls a record out of it — a reference from views/ or data/ to a
demo-only identifier fails, as it must.
depends remains available, and takes relative paths for files in other directories:
- data_type: UiMenu depends: - actions - ../security/security identifier: admin_menu name: Admin Menu action: admin_action groups: - - link - my_module_admin| Path Format | Description |
|---|---|
"actions" | Same directory (views/actions.yaml) |
"../security/security" | Parent + subdirectory (security/security.yaml) |
"../data/seed_data" | Parent + subdirectory (data/seed_data.yaml) |
These are ordering hints, not requirements: a reference to an identifier declared anywhere
in the same module resolves on its own. Reach for depends when a file must be imported
first for a reason no reference expresses — for example seed records whose calculate or
create override reads records another file creates.
Common Fields
Section titled “Common Fields”All other fields map to model fields:
- data_type: Product identifier: product_laptop name: Laptop price: 999.99 active: trueData Types
Section titled “Data Types”Groups (Group)
Section titled “Groups (Group)”- data_type: Group identifier: sales_user name: User category: SalesModel Access (ModelAccess)
Section titled “Model Access (ModelAccess)”- data_type: ModelAccess identifier: product_access name: Product Access model: Product group: sales_user read_perm: true write_perm: true create_perm: true delete_perm: falseViews (UiView)
Section titled “Views (UiView)”- data_type: UiView identifier: product_list_view name: product_list_view type: List model: Product arch: [...]Window Actions (WindowAction)
Section titled “Window Actions (WindowAction)”- data_type: WindowAction identifier: products_action name: Products model: Product modes: List,Form views: - - set - - product_list_view - product_form_viewMenus (UiMenu)
Section titled “Menus (UiMenu)”- data_type: UiMenu identifier: products_menu name: Products parent: sales_menu action: products_action sequence: 10Custom Models
Section titled “Custom Models”- data_type: CrmStage identifier: stage_new name: New sequence: 10 fold: falseRelationships
Section titled “Relationships”ManyToOne References
Section titled “ManyToOne References”Reference by identifier:
- data_type: Product identifier: product_phone name: Smartphone category: category_electronicsThe system resolves category_electronics to the actual record ID.
Parent Menu Reference
Section titled “Parent Menu Reference”- data_type: UiMenu identifier: sub_menu name: Sub Menu parent: main_menuUpdate Behavior
Section titled “Update Behavior”When a module is updated:
- Records with existing identifiers are updated
- New identifiers create new records
- Removed identifiers of data records keep their existing rows (no automatic deletion)
- Removed identifiers of managed records (
UiView,WindowAction,UiMenu,Group,ModelAccess,RecordRule,CronJob) are deleted, unless another module now declares the same identifier, in which case it takes ownership
Example: Complete Data File
Section titled “Example: Complete Data File”modules/crm/data/stages.yaml:
- data_type: CrmStage identifier: stage_new name: New sequence: 10 probability: 10 fold: false- data_type: CrmStage identifier: stage_qualified name: Qualified sequence: 20 probability: 30 fold: false- data_type: CrmStage identifier: stage_proposition name: Proposition sequence: 30 probability: 60 fold: false- data_type: CrmStage identifier: stage_won name: Won sequence: 100 probability: 100 fold: true- data_type: CrmStage identifier: stage_lost name: Lost sequence: 110 probability: 0 fold: trueData Inheritance
Section titled “Data Inheritance”When your module needs to modify records defined by another module (e.g., adding groups to an existing menu, adding implied_groups to a group), use the same identifier with command arrays for M2M fields.
How It Works
Section titled “How It Works”- Same identifier = update existing record
- Only specified fields are modified
- Command arrays control how M2M/O2M fields are updated
Command Types for M2M Fields
Section titled “Command Types for M2M Fields”| Command | Syntax | Description |
|---|---|---|
link | ["link", "identifier"] | Attach to the existing relations |
unlink | ["unlink", "identifier"] | Detach from the relations |
set | ["set", ["id1", "id2"]] | The relations become exactly these |
clear | ["clear"] | Detach every relation |
Example: Add Implied Groups
Section titled “Example: Add Implied Groups”Your module can add implied groups to an existing group:
- data_type: Group identifier: sales_manager_group implied_groups: - - link - my_new_group - - link - another_groupThis adds groups to the existing implied_groups (doesn’t replace).
Example: Modify a Menu
Section titled “Example: Modify a Menu”Change an existing menu’s parent or sequence:
- data_type: UiMenu identifier: crm_pipeline_menu parent: my_module_root_menu sequence: 5Example: Add Views to an Action
Section titled “Example: Add Views to an Action”Add your custom view to an existing action:
- data_type: WindowAction identifier: pipeline_action views: - - link - my_custom_pipeline_viewExample: Add Group Restrictions to a Menu
Section titled “Example: Add Group Restrictions to a Menu”Restrict an existing menu to specific groups:
- data_type: UiMenu identifier: admin_menu groups: - - link - my_admin_groupReplace vs Add
Section titled “Replace vs Add”Use set when defining the complete set in the original module:
- data_type: Group identifier: sales_admin name: Sales Administrator implied_groups: - - set - - sales_user_group - crm_user_groupUse link when extending from another module (adds to what is already there):
- data_type: Group identifier: sales_admin implied_groups: - - link - my_extra_permission_groupWhat Can Be Extended?
Section titled “What Can Be Extended?”Any record type with an identifier can be extended:
| Record Type | Common Extensions |
|---|---|
Group | Add implied_groups, change category |
UiMenu | Change parent, sequence, action, add groups |
WindowAction | Add views, modify context |
ModelAccess | Change permissions |
RecordRule | Modify filter |
| Seed data | Modify defaults |
Scaffolding a Module
Section titled “Scaffolding a Module”To scaffold a new module skeleton (directories, manifest, __init__.py), use:
fullfinity-server new my_module# --path <dir> to choose where it is created (default: current directory)Record extensions are then written by hand in the new module’s data files — add a record
with the same identifier as the record you want to extend (see the command-array
examples above).
Uninstall Behavior
Section titled “Uninstall Behavior”When a module is uninstalled:
- Records owned by the module are deleted - only records where
modulefield matches the uninstalling module - Dependencies are updated - all parent modules are updated to restore their original state
- Extensions are automatically reverted - because parent modules re-import their JSON files with
["set", [...]]commands
This means:
- Scalar field changes made by the uninstalled module are restored
- M2M links added by the uninstalled module are removed
- ManyToOne references to deleted records are restored to originals
Important: For this to work correctly, original modules should use ["set", [...]] for M2M fields, not ["link", ...].
Shipping Help Articles
Section titled “Shipping Help Articles”A module can ship end-user help as data: KbCategory and KbArticle records in data/,
published by the Help Center (helpdesk_knowledge) at /help. The article body is HTML in
content; screenshots go in the module’s static/ folder (listed in static_paths) and
are referenced by their served path.
- data_type: KbCategory identifier: acme_help_category_widgets name: Widgets icon: bi-box description: Build, stock and ship widgets.
- data_type: KbArticle identifier: acme_help_ship_a_widget title: How do I ship a widget? slug: ship-a-widget category: acme_help_category_widgets company: null # shared: shown on every company's help center is_published: true summary: Pick, pack and dispatch a widget order. content: | <p>Open <strong>Widgets → Orders</strong>, then click <strong>Ship</strong>.</p> <p><img src="/acme_help/static/images/help/ship.png" alt="A widget order ready to ship"></p>Set company: null explicitly. An article’s company otherwise defaults to the installing
user’s, which hides it from every other company’s help center.
Keeping articles current
Section titled “Keeping articles current”An article keeps rendering after the screen it describes changes, so nothing tells you it
went stale. Declare what each article depends on in help_coverage.yaml at the module
root (or split it into one file per app under help_coverage/), and
./fullfinity-server check --only help holds the articles to it:
articles: acme_help_ship_a_widget: # the KbArticle identifier actions: [acme_widget_order_action] menus: [acme_widget_orders_menu] buttons: [WidgetOrder.action_ship] # Model.method of a button on that model's views fields: [WidgetOrder.carrier] # Model.field site: [acme_shop] # modules whose WEBSITE pages it shows: the text of # their templates and island components countsThe check fails when:
- an article in
data/has no entry, or an entry names no article; - a covered action, menu, button or field no longer exists;
- a
<strong>in an article is not a label on the screens the article covers: the views of the models its entry names (through its actions, menus, buttons and fields) and the views those embed, those models’ Selection values and shipped records, the covered actions’ own labels, plus the interface’s own text and menu names. A label that exists only on some other screen fails, so add that screen to the entry if the article really sends the reader there; - an arrowed menu path such as
Widgets → Ordersis not a real chain of menus; - an image from the module’s own
static/folder is missing; - an article places a panel by its side (“the panel on the right”, “the left-hand panel”).
A form’s details panel sits on the left unless the form sets
side: right, and the whole layout mirrors in right-to-left languages. Name the panel (“the details panel”) or quote its title instead.
In an article, <strong> means “a label you will see on screen” and is checked. Write
emphasis as <em>. A button with no label: is quoted by its derived label, its method as
words (action_ship → “Ship”).
The check also lists, without failing, the buttons on covered screens that no article mentions yet.
Removing an article
Section titled “Removing an article”A data file never deletes a record it stops declaring (see Update Behavior),
so an article removed from data/ stays published. If articles are maintained in the
module, remove the stale ones in a post_install/post_update hook in the module’s
__init__.py: give every shipped identifier a common prefix, and delete the records with
that prefix that no data file declares.
Best Practices
Section titled “Best Practices”- Use descriptive identifiers -
product_laptopnotprod1 - Group related data - Separate files for stages, tags, etc.
- Order matters - Dependencies must be defined first
- Immutable identifiers - Never change identifiers after release
- Keep data minimal - Only include essential seed data
- Use Link for extensions - Use
linkcommand when extending records from other modules - Use Replace for definitions - Use
setcommand when defining the complete set in your own module
Next Steps
Section titled “Next Steps”- Creating Modules - Full module tutorial
- Security - Groups and permissions
- View Inheritance - Extending views