diff --git a/SKILL.md b/SKILL.md index 9259fb5..134e84e 100644 --- a/SKILL.md +++ b/SKILL.md @@ -146,7 +146,16 @@ are heavy; allow several minutes. Industry-appropriate, minimal but believable, generated from the brief — the client's own partners, products, projects and orders, staged so each hero has a record to fire on. Drive it from a `demo_config.json` (see `demo_config.example.json`) and -`scripts/build_demo.py`. Rules: +`scripts/build_demo.py`. + +**`build_demo.py` is a per-engagement template, not an engine.** It implements one shape +(products, fleet, credit limits, prestaged receivables) and reads every key with +`cfg.get()`, so anything it does not implement would otherwise be skipped in silence — a +`DONE` over an empty database. It now refuses to run on config keys it cannot build, listing +them; extend the script, or drop the keys. `DEMO_ALLOW_UNKNOWN_KEYS=1` overrides for a +deliberate partial run. Extend `KNOWN_KEYS` whenever you add a block. + +Rules: - **Get-or-create by name** so re-runs are idempotent. - Set the right **currency** first (activate it with `context={'active_test': False}`, set diff --git a/scripts/build_demo.py b/scripts/build_demo.py index 06f490c..53c6c78 100644 --- a/scripts/build_demo.py +++ b/scripts/build_demo.py @@ -14,6 +14,24 @@ from odoo_connect import x, get_or_create, URL, DB CFG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "demo_config.json") cfg = json.load(open(CFG, encoding="utf-8")) +# Every key below is read with cfg.get(), so anything this script does not know about is +# silently skipped. That is how a vertical config (take-offs, progress statements, ...) fed +# to the stock builder prints DONE over an empty database. Fail loudly instead: this script +# is a per-engagement TEMPLATE, and an unknown key means it has not been adapted yet. +KNOWN_KEYS = { + "client", "currency", "use_credit_limit", "scope_modules", "products", "customers", + "vehicles", "pricelist", "prestage_receivables", "heroes", +} +unknown = sorted(k for k in cfg if k not in KNOWN_KEYS and not k.startswith("_")) +if unknown: + print("!! demo_config.json has keys this builder does not implement:") + for k in unknown: + print(f" {k}") + print("!! They will NOT be created. Either extend this script to handle them, or") + print("!! remove them so the config reflects what actually gets built.") + if os.environ.get("DEMO_ALLOW_UNKNOWN_KEYS") != "1": + raise SystemExit("aborting: unimplemented config keys (set DEMO_ALLOW_UNKNOWN_KEYS=1 to override)") + # 1. currency (must run before invoices) cur = cfg.get("currency") if cur: