Wizard dialogs
A wizard is a record form opened over its caller by an exposed object method. Use a transient model for its temporary input and ordinary models for durable business results. Native and WASM methods share the server action-result normalizer and the human client’s dialog controller (ADR 0088).
This page describes the merged authoring contract. Installed native/WASM checks cover the sample lending flow, including confirmation, cancellation and access denial. They do not establish complete behavior parity; the limitations below still apply.
Declare and expose the wizard
Section titled “Declare and expose the wizard”The existing sample at examples/wasm/sample_library_wasm/src/lib.rs uses
#[model(name = "sample_library.lend.wizard", kind = "transient", ...)], required
Many2one<Book> and Many2one<Partner> fields, and a required Option<Date> due
date. This is the shared erp-sdk declaration surface for native and component
targets. A WASM method opts into client calls with #[method(wire, rpc)]; use the
native method exposure described in RPC for native-only addons.
Declare ordinary access rows for the wizard and every business model it uses. A transient declaration or window action grants no elevated access. The normalizer checks read access to the target model; the subsequent reads, saves and object method still run with the caller’s authority.
Package the form with the addon data files. A direct, last <footer> holds the
object method button and a cancel button with no method:
<form string="Lend Book"> <group> <field name="book_id"/> <field name="borrower_id"/> <field name="due_date"/> </group> <footer> <button name="action_confirm" type="object" string="Lend" class="btn-primary"/> <button special="cancel" string="Cancel" class="btn-secondary"/> </footer></form>The sample defines requiredness on the model, with no contradictory field-node
modifiers. book_id is also readonly = true on the model (since 1.3.2): the
Lend button sets it through default_book_id, the form shows it read-only, and
create takes it from the context because the client does not send read-only
fields. A footer is omitted on the main-route form. Load each added view
through get_views in a test as a user who opens it; method tests alone do not
establish that the form can render.
Return a bounded action
Section titled “Return a bounded action”The sample’s lend method returns this shape, filling the book id and calendar
date from its own authorized record and date calculation:
{ "type": "ir.actions.act_window", "name": "Lend Book", "res_model": "sample_library.lend.wizard", "target": "new", "views": [[false, "form"]], "context": {"default_book_id": 1, "default_due_date": "2026-11-11"}}The id and date above are illustrative, not measured output. Return literal
default_<field> values only, naming actual target fields. Do not return
active_*, session, language or company selectors: the client composes those
from its authenticated caller binding. Exactly one form selection is admitted;
use views or view_id/view_mode, never both. An optional res_id must be
positive and JSON-safe. Main-route actions and other view types are refused.
The complete result is limited to 16 KiB serialized and depth 6. Context has at most 64 keys, model names at most 256 bytes, notification messages at most 4096 bytes and titles at most 256 bytes. Unknown members and wrong types fail by name.
After validation/save, the sample’s action_confirm reads the saved borrower
and due date, creates a durable loan and marks the book unavailable. It returns
ir.actions.client with tag display_notification, text params.message,
optional params.title, params.type = "success", and
params.next = {"type":"ir.actions.act_window_close"}. Levels also admit
info, warning and danger. HTML rendering, links, sticky notifications and arbitrary
action chains are outside this contract. An explicit close admits no additional
members. Scalar results (null, booleans, numbers, strings) mean no action; arrays
are refused.
Lifetime, errors and limitations
Section titled “Lifetime, errors and limitations”Confirm validates and saves before the exposed method. Cancel does neither. Dismissal through Escape, close, replacement or navigation discards wizard edits without a prompt; a pending or uncertain write cannot be blindly dismissed. Close/no-action ends the dialog and refreshes its caller once without changing the caller route. Notification content is text.
If the method response or its presentation is uncertain, do not retry the method: readback does not establish whether another business write is safe. The client keeps that operation read-only. An ambiguous save of an existing record has a separate readback recovery path; new-record defaults cannot prove that creation committed.
Component onchange contributions remain unsupported; sharing the form’s initial onchange transport does not add guest onchange support. WASM field declarations currently admit many2one, date and datetime alongside the scalar kinds listed in WASM addons; other relational field declarations remain refused. Transient expiry, vacuum and cleanup takeover are planned. No cleanup guarantee follows from closing a dialog.
Cleanup policy (operator-run, not scheduled)
Section titled “Cleanup policy (operator-run, not scheduled)”A transient model can declare how long its rows may live. Two optional model
parameters carry the policy (ADR 0092); the same names work in #[model] /
#[extend], in the TOML of a data-only addon (transient_max_age_seconds = 7200)
and in a WASM addon, which declares them through the same macro:
| Parameter | Meaning | Default |
|---|---|---|
transient_max_age_seconds | rows older than this may be removed | 3,600 (one hour) |
transient_max_count | the most rows the model keeps; the oldest surplus may be removed | not limited |
#[model( name = "sample_library.lend.wizard", kind = "transient", transient_max_age_seconds = 7_200, transient_max_count = 500)]Rules, checked when the registry is built (a wrong declaration fails the addon load; nothing is defaulted silently):
0disables that threshold. Disabling both is allowed; the registry reports it (TransientPolicy::is_cleanup_disabled).- Values are plain non-negative integers: the age is at most 315,360,000 seconds
(ten 365-day years), the count at most
i64::MAX. Negative numbers, floats, strings, suffixes (3600u64), hex literals and overflow are refused with the model and the parameter named. - Only a transient model may declare them. A regular or abstract model that does is refused, naming the model and the parameter.
- An in-place extension (
#[extend],extend = "…") inherits the policy of the model it extends; a parameter it states itself overrides the inherited one, a parameter it leaves out is kept. - Native and WASM declarations compose the same validated policy
(
ModelSpec::transient_policy).
The cleanup is inactive until an operator runs or schedules it. The ORM has a cleanup
engine for transient models, Orm::vacuum_transient(model, VacuumOptions) (ADR 0092). It is
a host-only library call: it opens its own system-principal transactions, takes no principal
or context, and is not an RPC method, a model method or a WASM import, so an addon cannot call
it. The operator entry point is the command erp db vacuum-transient
(see Running the transient cleanup). No scheduler,
worker or request starts a cleanup, so a deployment removes no transient row until an operator
runs the command or schedules it. Until then, treat transient rows as permanent for
operational purposes.
Operator section
Section titled “Operator section”erp db vacuum-transient --config /etc/erpforall/server.toml --model sample_library.lend.wizard --max-rows 5000erp db vacuum-transient --config /etc/erpforall/server.toml --allHost code that already holds an Orm (a test, or the operator tooling) calls the engine
directly. The block below only illustrates the engine’s options (it is not compiled); the CLI argument
example that is compiled as a doc test is on VacuumTransientArgs::options in erp-cli.
use erp_orm::{VacuumOptions, VacuumOutcome};
let options = VacuumOptions::default().max_batch_rows(200)?.max_rows(5_000)?;assert_eq!((options.batch_rows(), options.rows()), (200, 5_000));// the hard caps cannot be raised or disabledassert!(VacuumOptions::default().max_rows(0).is_err());assert_ne!(VacuumOutcome::Completed, VacuumOutcome::Pending);# Ok::<(), erp_fields::Error>(())Write your unlink overrides so that they can fail only for a reason an operator can fix: a
failing override on the oldest rows blocks every later call (the operations page describes the
remedy).
What a call does, once a host invokes it:
- It removes rows through the normal
unlinkchain, so yourunlinkoverrides, relation effects and errors behave as for any deletion (under the system principal). An error in your override rolls that batch back and is returned unchanged. - Age: rows whose last write (
write_date, elsecreate_date) is strictly before the cycle start minus the age (never less than 300 seconds). Count, after age: when the table holds more rows than the limit, every row older than 300 seconds goes, not just enough to get under the limit. A row written in the last 300 seconds is never removed. - It is safe on several replicas: a lease row in the tenant database
(
erp_transient_vacuum_state, created bysync_schema) decides who works. The report saysBusy,NotDue,LostLease,Completed,Pending(stopped early or rows are locked by others: call again),BudgetExhausted,PolicyChangedorDisabled, with the committed row and batch counts. - Bounds: 1,000 rows per batch, 100 batches and 100,000 rows per cycle (persisted, a
takeover does not reset them), a new cycle at most every 300 seconds.
VacuumOptionscan lower the caps of one call, never raise them. The caps bound the rows selected directly; anunlinkoverride or cascade may touch more. - Rollback and backup: deleted rows cannot be restored by restoring an old executable. Disable the invocation first, then change the schema or policy.