How to scaffold a new addon
Goal: create a valid module tree with manifest, Go model stub (sdk.Model tags), starter views, menus, and security files.
There are two entry points. Prefer the custom workspace unless you are contributing a module inside the kernel repo.
Prerequisites
- Go toolchain per
sumeru/go.mod - Sibling layout:
sumeru/,sumeru_addons/,sumeru_custom_addons/
Custom workspace (usual path)
From sumeru_custom_addons/:
make new MODULE=my_module
make install MODULES=my_module
make run
make new runs sumeru-bp into addons/ then make generate. Generated files (do not hand-edit):
| File | Role |
|---|---|
models/zmodels.go | sdk.MustRegister for each sdk.Model struct |
models/zrefs.go | Typed relation handles when you use cross-module Many2One types |
init.go | Blank-import of models/ only — rewritten on every generate |
addonimports/zimports.go | Workspace blank-imports for discovered addons |
Put event hooks and object actions in models/ (or another package imported from models/). Do not put lasting logic in custom-workspace init.go.
Use **^[a-z][a-z0-9_]*$ for the module name (e.g. sale_demo, not SaleDemo**).
Core repo (sumeru/addons)
When scaffolding inside the kernel checkout:
cd sumeru
make bp NAME=my_module
make generate
go run ./cmd/sumeru -- -c sumeru.conf -i my_module --stop-after-init
make bp is go run ./cmd/sumeru-bp -- -bp NAME. There is no scaffold subcommand and no WITH_MODELS flag. Models use sdk.Model tags; registration is always generated.
Custom output directory:
go run ./cmd/sumeru-bp -- -bp my_module -out addons
Default is already addons/ under the detected repo root.
What the scaffold emits
Copied from sumeru/cmd/sumeru-bp/templates/:
models/models.go—sdk.Model+sdk.String/sdk.Text/sdk.Boolean/sdk.Integertagsviews/list_view.xml(nottree_view.xml)views/form_view.xml,views/kanban_view.xml,views/actions.xml,views/menus.xmlsecurity/sys.access.csv(notir.model.access.csv)- Window action as
sys.action.window