Skip to content
ERPForAll DocsDevelopment

    Stock read models

    erp_addon_stock::position::stock_position takes a bounded PositionRequest inside a primary repeatable-read transaction. It reads current quants and open stock moves under the caller’s access. The report’s current scope selects active warehouse roots by default. A caller can pass explicit location roots, including an empty list. Descendants are included unless the request selects strict roots. Current scope membership uses the location tree. A move counts only if it crosses the selected location boundary. Open moves use stored demand converted to the product unit.

    Every quantity is in the product’s stock unit and displayed at the configured Product Unit precision. Free to Use subtracts reserved quantity. Forecasted adds rounded incoming demand to exact on hand, subtracts rounded outgoing demand, and rounds the result. The contributing predicates are available through PositionBatch::drill_sources and must be evaluated with the caller’s current rights.

    The stock addon installs the stock.report_current_product_position definition and the stock.action_current_product_position client action at version 1.14.0. Inventory users open it through Inventory > Reporting > Product Stock Position. The provider works with the existing report options, rows and drill routes. Its options.provider accepts category_id, location_ids and strict. Category filtering includes descendants. On Hand and Free to Use open quants. Incoming and Outgoing open the moves selected by the same predicates. Forecasted combines those source sets and its cell has no single-source drill.

    The normalized report options return filters.provider = "stock.current_product_position" and filters.server_search = true. The screen and both export formats use the search results from the provider. Search matches the product name or internal reference with the ORM’s case-insensitive ilike operator. The eligible set is caller-visible tracked products belonging to a selected company or shared across companies. The category option further limits it to that category and its descendants. Drill admission uses the product and its category, company and location scope. A displayed label may include the internal reference or variant attributes.

    Technical > System Parameters exposes stock.position_max_source_rows. It counts admitted quant and move rows before reading their aggregates. Its default is 10,000, with a hard range of 1 to 1,000,000. A request beyond the limit is refused. Narrow the product or location selection. The request also caps the product list at 1,000 and separate company and location lists at 256.

    The sections below describe the full contract for later stock read slices.

    The proposed native stock service accepts a validated batch of products, companies, warehouse/location scope, optional dates and dimensions in the caller’s transaction. It returns exact on-hand, reserved, incoming, outgoing, free and forecast quantities, plus units and a result identity. Addons consume the service rather than querying its projection tables or maintaining a second supply/demand total. Stock accounting keeps ownership of values; a quantity result is not a valuation approval.

    Explicit empty scope means zero for permitted products; an empty product list returns an empty batch. Absence of company selection uses the environment’s allowed companies. Forbidden explicit companies or locations fail access checks. Warehouse unions classify movements once: a transfer inside the union is neither incoming nor outgoing. Overlapping roots do not duplicate quantities.

    Legacy context adaptation remains separate from the typed boundary. Location and warehouse name matching keeps substring behavior, with warnings containing only authorized candidates. Strict-name matching is opt-in. Unknown options and invalid types fail; they do not choose a broader default scope.

    Lot, owner and package restrictions have different meanings for physical stock and open moves. Package filters constrain current quant quantities, not planned move supply. A lot filter counts each qualifying open move once. Nullable owner selectors distinguish unrestricted, ownerless and named owners; an empty legacy owners set means ownerless, not every owner.

    Past product-field quantities reconstruct exact historical on-hand while reporting current reservations. Results label this reservation basis. Historical reservation, lot/package attribution, expiry and warehouse-topology reconstruction are unsupported in the first proposed version. They return an explicit error; a daily checkpoint cannot silently answer a question it lacks the dimensions to cover.

    Date-only boundaries use UTC days; timestamp queries preserve intraday precision. Backdated movements and corrections can change a later query for an old business date. Sparse checkpoints accelerate the complete ledger fold and cannot replace missing history with zero. Removing acceleration data does not delete source facts.

    Every contributing source must satisfy current model, field, company and record access. A company-filtered total is insufficient when record rules distinguish rows within it. The service uses a declared exact-source plan or refuses an unsupported request when aggregate grain cannot preserve visibility.

    Operational decisions and post-write product blocks use primary transactions. Analytical browsing may use a bounded-lag replica with visible route and freshness information. Unknown lag is not a fresh result. The service cannot upgrade an already-open replica transaction secretly; the caller must select the required consistency before opening it.

    Quantity payloads belong to an authorized transaction or report run. Changes to principal, elevation, companies, policy, options or generations require a new identity and authorization decision. Addons must not reuse an earlier quantity payload merely because its products and company IDs match.

    Forecast display pages contain at most 200 lines, while reconciliation covers the entire admitted demand universe. A refreshed load-more prefix replaces the old prefix and totals together; it cannot append rows from a new snapshot to old totals. Large requests fail a declared limit or use a durable report workflow. Default-scope search, sort and group use the same rounded measures displayed on product fields, including zero for authorized products without stock rows.

    Extensions for expiry, rental or subscription demand must declare their semantics and version. Missing required providers, unknown options, overflow and exceeded budgets fail with explicit error kinds and messages. Providers cannot relax authorization or admission limits. The legacy quantity-report model name is not a general addon compatibility promise.

    Future projection setup builds and validates generations before marking them ready. An unavailable generation must use an admitted exact-source plan or fail visibly; missing initialization is not empty stock. Maintenance will use bounded, fenced jobs with explicit source-equivalence checks. Opening a report will not start an unbounded repair or replay. Operational commands and runtime examples will accompany the implementation slices.