Search domains for nonstored fields
ADR 0086 remains Proposed until the designated lead merges it; the lead accepted
the design in substance on 2026-10-31.
A nonstored field can name search_method = "_search_flag" alongside its
compute method. Declare the provider with #[search_method] inside the
model’s ordinary #[methods(Model)] implementation. The compiling example
is ResPartner::_search_has_vat in addons/base/src/res_partner.rs; the
independent fixture and override are in
crates/erp-test-models/tests/search_method.rs.
The synchronous signature is
fn(&FieldSearchRequest<'_>, &mut FieldSearchContext<'_>) -> Result<Domain>.
An override adds FieldSearchSuper<'_> as the third parameter and uses
#[search_method(override)]. Call sup.call(req, ctx) to delegate. The
request exposes operator() and operand(); it cannot be constructed or
mutated by an addon. The context exposes the environment and original
model/field through getters, plus charge_work(units) for cooperative
calculation. Charge explicit iterative work with ctx.charge_work(1)? on each
iteration. It supplies no transaction, cursor, commit hook or SQL API.
Native addon code remains trusted Rust, not sandboxed executable code.
Return a domain over stored fields or other searchable nonstored fields, with no database scan or filtering of loaded records. The complete returned predicate stays inside each relational path’s existential scope. Ordinary field access and model/record/company rules still apply. Hierarchy and access operators enter ordinary preparation after expansion. Missing or duplicate providers, wrong types, unsupported operators, cycles and resource exhaustion return errors. Catching a failed continuation cannot recover an operation. Stored fields cannot declare this callback.
Boolean requests accept equality, inequality and membership/nonmembership
with Boolean values. Other scalar field types use typed comparison and
membership operands; textual fields also accept pattern operators. JSON
and range operands have no search-provider contract in this proposal and
are refused. Domain null uses Value::Bool(false) for nullable scalar fields.
The hard ceilings are 32 active provider expansions, 4096 expanded AST
nodes, 8192 work units, 256 native AST/value depth and 1048576 copied
text/value bytes per expansion operation. ORM configuration may lower
positive provider/node/work limits, never raise or disable them. Returned
custom nodes, opaque values and internal traversal operators (any!, not any!)
are refused. Internal traversal operators are reserved for framework-generated
predicates. No product performance claim
is made; measurement stays deferred to milestone end.
A malformed domain produced by a provider is a Programming error naming its method, model and field, including when a user supplied the original external search. Invalid original external operands remain Validation errors. Access refusals retain their Access kind; a provider does not gain permission through translation.
Native relational predicates accept both Value::Domain and list-syntax
operands for any/not any; providers expand before ordinary hierarchy and
access preparation in either form. Framework callers that explicitly parse
trusted native list syntax use Domain::from_list_native: it reports
Programming errors and preserves nested provider contexts. External list
constructors keep their Validation contract. This constructor does not grant
a provider permission to return internal traversal operators; provider output
admission still rejects them. Parsing a provider list and admitting its
materialized AST consume the same operation-local budget as its raw values.
Hierarchy seeds from a search method
Section titled “Hierarchy seeds from a search method”A provider can return ('id', 'child_of', Value::Domain(sub)) (or parent_of), where sub is a
typed domain on the same model. This is the typed form of Odoo’s
[('id', 'child_of', self._search(domain))] (a tag name search that includes descendants). The
sub-domain is searched with the caller’s access rules when the hierarchy is resolved, exactly like a
start record given by name, and the walk is unchanged (SPEC-DOM-091). The external JSON syntax has
no such operand and still refuses a list of lists as a start value.