Skip to main content
A Stock Request is the core model in the Stock Request framework that represents an individual request for a specific product and quantity. Stock Requests can be created independently or grouped together within a Stock Request Order.

Overview

The Stock Request model (stock.request) inherits from stock.request.abstract and provides functionality to request products at a specific location, track their fulfillment through stock moves, and manage the complete lifecycle from draft to completion.
Stock Requests are defined in stock_request/models/stock_request.py:9

Key Features

Lifecycle Management

Track requests through draft, open, done, and cancelled states

Allocation Tracking

Monitor stock moves and allocations linked to the request

Quantity Tracking

Track quantities in progress, done, and cancelled

Procurement Integration

Automatically trigger procurement rules and transfer generation

States

Stock Requests follow a defined lifecycle with four possible states:
1

Draft

Initial state when a stock request is created. Requests can be modified or deleted in this state.
2

In Progress (Open)

The request has been confirmed and procurement rules have been triggered. Stock moves are being processed.
3

Done

The request has been fully fulfilled. All requested quantities have been allocated and received.
4

Cancelled

The request has been cancelled. Associated stock moves are cancelled.
state = fields.Selection(
    selection=[
        ("draft", "Draft"),
        ("open", "In progress"),
        ("done", "Done"),
        ("cancel", "Cancelled"),
    ],
    string="Status",
    default="draft",
)

Essential Fields

Identification and Tracking

FieldTypeDescription
nameCharUnique identifier for the stock request
stateSelectionCurrent status of the request
requested_byMany2one (res.users)User who created the request

Product and Location

FieldTypeDescription
product_idMany2one (product.product)Product being requested
product_uom_idMany2one (uom.uom)Unit of measure for the request
product_uom_qtyFloatRequested quantity in UoM
location_idMany2one (stock.location)Destination location for the product
warehouse_idMany2one (stock.warehouse)Warehouse associated with the request

Dates and Policies

FieldTypeDescription
expected_dateDatetimeWhen you expect to receive the goods
picking_policySelection”direct” (receive each product when available) or “one” (receive all at once)

Relationships

FieldTypeDescription
order_idMany2one (stock.request.order)Parent order if this request is part of an order
allocation_idsOne2many (stock.request.allocation)Allocations linking to stock moves
move_idsOne2many (stock.move)Stock moves generated for this request
picking_idsOne2many (stock.picking)Transfer operations associated with this request
procurement_group_idMany2one (procurement.group)Procurement group for generated moves
route_idMany2one (stock.route)Specific route to use for procurement

Quantity Fields

Stock Requests track three computed quantity fields:
qty_in_progress = fields.Float(
    digits="Product Unit of Measure",
    readonly=True,
    compute="_compute_qty",
    store=True,
    help="Quantity in progress.",
)

qty_done = fields.Float(
    digits="Product Unit of Measure",
    readonly=True,
    compute="_compute_qty",
    store=True,
    help="Quantity completed",
)

qty_cancelled = fields.Float(
    digits="Product Unit of Measure",
    readonly=True,
    compute="_compute_qty",
    store=True,
    help="Quantity cancelled",
)
These quantities are automatically calculated based on the allocations and their associated stock moves (stock_request.py:162).

Key Methods

Confirmation

def action_confirm(self):
    self._action_confirm()
    return True
Confirms the stock request, launching procurement rules and transitioning to “open” state (stock_request.py:268).

State Transitions

def action_draft(self):
    self.write({"state": "draft"})
    return True
Returns the request to draft state.

Procurement

def _action_launch_procurement_rule(self):
    """
    Launch procurement group run method with required/custom fields
    generated by a stock request. Procurement group will launch
    '_run_move', '_run_buy' or '_run_manufacture' depending on
    the stock request product rule.
    """
This method (stock_request.py:381) triggers the procurement engine to generate stock moves, purchase orders, or manufacturing orders based on the configured routes.

Use Cases

Inventory Replenishment

Request products to replenish stock at a specific warehouse location

Internal Transfers

Request products to be moved between locations within the company

Purchase Requests

Trigger purchase orders automatically through procurement rules

Manufacturing Requests

Initiate manufacturing orders for products that need to be produced

Constraints and Validations

Stock Requests enforce several important constraints:
  • Product quantity must be strictly positive in draft state
  • Product quantity cannot be negative in other states
  • Stock Request names must be unique per company
  • Only draft requests can be deleted
  • If part of an order, key fields must match the parent order

Example: Creating a Stock Request

stock_request = env['stock.request'].create({
    'product_id': product.id,
    'product_uom_id': product.uom_id.id,
    'product_uom_qty': 10.0,
    'warehouse_id': warehouse.id,
    'location_id': location.id,
    'expected_date': fields.Datetime.now(),
    'requested_by': env.user.id,
})

# Confirm the request to trigger procurement
stock_request.action_confirm()

Relationship to Products and Locations

Stock Requests establish a clear link between products and locations:
  • Product: Must be a storable product or consumable (type in ['product', 'consu'])
  • Location: Typically an internal or transit location where the product is needed
  • Warehouse: Provides context for route evaluation and procurement rules
  • Route: Determines how the product will be sourced (buy, manufacture, or move)
The framework automatically evaluates available routes based on the product, warehouse, and location configuration (stock_request_abstract.py:116).

Build docs developers (and LLMs) love