Skip to content
ERPForAll DocsDevelopment

    Load demo data on an existing database

    A database created without --with-demo has no demo records and every module has demo = false. Odoo’s “Load demo data” (base.demo_force_install_action, ir.demo.install_demo) makes such a database a demo database afterwards. ERPForAll has the same operation as a module lifecycle operation (ADR 0153).

    It cannot be undone. Nothing removes demo records afterwards. Use it on test databases only.

    1. Sets demo = true on every module row, installed or not.
    2. For every installed module, in dependency order, loads the files listed in the manifest’s demo key. Each module’s demo files load as superuser in one savepoint, in init mode, so noupdate demo records are written the way they are at install.
    3. Does not load the data files again and does not touch the schema. A record an administrator changed in a data file keeps the change.
    4. Writes one force_demo row to erp_module_lifecycle_audit (actor, session, outcome).

    Odoo also sets the auth_password_policy.minlength parameter to 4. ERPForAll does not; an addon whose demo users need a weaker password policy sets it in its own demo file.

    A module whose demo files fail on their data (a parse error, an unknown model, a refused value) is rolled back alone: none of its demo records stay, its demo flag becomes false, the other modules still load (a module that depends on it is not skipped). The operation commits and the reply names each failed module with the loader’s text:

    {"loaded": ["base", "x", "y"], "failed": [{"module": "bad", "error": "Module \"bad\": demo file 'demo/broken.xml' failed ..."}]}

    The Apps page shows the list. In Rust the same data is OperationOutcome::data_notices with NoticeKind::DemoFailed, and a row in ir.demo_failure when a registry declares that model. A failure of the database itself (a refused statement) fails the whole operation and nothing persists. Odoo only logs a warning here; ERPForAll reports it to the administrator who pressed the button.

    Running it twice does not duplicate anything: demo records keep their external ids and are updated in place. A module installed afterwards gets its demo files when every module it depends on has demo = true, which it has after this operation (the rule of SPEC-MOD-033).

    CallerEntry point
    Browser (administrator session)Settings ▸ Addons ▸ Load demo data, which posts {"confirm":true} to POST /erp/module/force-demo. The route takes a primary browser session only (no Authorization header) and WebLifecycle::force_demo rechecks the system group under the lifecycle lock.
    RustModuleSystem::force_demo(&env) (superuser environment) or ModuleSystem::force_demo_authorized(&authorizer) (browser seam). Switch to OperationOutcome::orm afterwards like any lifecycle operation.

    Odoo reaches the operation through a transient model ir.demo with a confirmation form. ERPForAll has no such model: the module system holds the lifecycle lock and the new registry, which a model method cannot, so the confirmation is the dialog of the Apps page and the confirm field of the request.

    • List demo records in the manifest’s demo key, never in data; give every record an id, so a second run updates it.
    • A demo file may rely on the module’s own data records and on its dependencies’ records, not on demo records of a module that does not depend on yours.
    • Keep one module’s demo files independent of another module’s demo failing: the flag is forced on every module, so your demo loads even when a dependency’s demo was rolled back.