Skip to main content
A Stock Request Order is a container model that groups multiple Stock Requests together. It provides a way to manage several product requests as a single unit with shared parameters.

Overview

The Stock Request Order model (stock.request.order) allows you to create and manage multiple stock requests that share common attributes like warehouse, location, expected date, and shipping policy.
Stock Request Orders are defined in stock_request/models/stock_request_order.py:8

Difference Between Request and Order

Stock Request

  • Represents a single product request
  • Can exist independently or within an order
  • Has its own state and lifecycle
  • Directly linked to stock moves and allocations

Stock Request Order

  • Groups multiple stock requests together
  • Provides shared parameters for all child requests
  • State is computed from child requests
  • Actions cascade to all child requests

Key Features

Grouping Requests

Orders provide a convenient way to manage multiple product requests:
stock_request_ids = fields.One2many(
    "stock.request", inverse_name="order_id", copy=True
)
All stock requests within an order share common attributes that are synchronized automatically (stock_request_order.py:122).

Shared Parameters

When you set parameters on an order, they cascade to all child requests:
1

Warehouse & Location

All requests in the order use the same warehouse and destination location.
2

Expected Date

The expected delivery date is synchronized across all requests.
3

Requested By

The user who requested the products is the same for all items.
4

Shipping Policy

Controls whether products are received individually or all at once.
def change_childs(self):
    if not self._context.get("no_change_childs", False):
        for line in self.stock_request_ids:
            line.warehouse_id = self.warehouse_id
            line.location_id = self.location_id
            line.company_id = self.company_id
            line.picking_policy = self.picking_policy
            line.expected_date = self.expected_date
            line.requested_by = self.requested_by
            line.procurement_group_id = self.procurement_group_id
This method (stock_request_order.py:289) ensures child requests stay synchronized with the order.

States

Unlike Stock Requests, the order’s state is computed from its child requests:
@api.depends("stock_request_ids.state")
def _compute_state(self):
    for item in self:
        states = item.stock_request_ids.mapped("state")
        if not item.stock_request_ids or all(x == "draft" for x in states):
            item.state = "draft"
        elif all(x == "cancel" for x in states):
            item.state = "cancel"
        elif all(x in ("done", "cancel") for x in states):
            item.state = "done"
        else:
            item.state = "open"
(stock_request_order.py:211)

State Logic

Order StateCondition
DraftNo child requests OR all child requests are in draft
OpenAt least one child request is open (in progress)
DoneAll child requests are done or cancelled
CancelAll child requests are cancelled

Essential Fields

Identification

FieldTypeDescription
nameCharUnique identifier for the order
stateSelectionComputed state based on child requests
requested_byMany2one (res.users)User who created the order

Location and Timing

FieldTypeDescription
warehouse_idMany2one (stock.warehouse)Warehouse for all requests
location_idMany2one (stock.location)Destination location for all products
expected_dateDatetimeExpected delivery date
picking_policySelectionShipping policy for all requests

Relationships

FieldTypeDescription
stock_request_idsOne2many (stock.request)Child stock requests in this order
move_idsOne2many (stock.move)All stock moves from child requests
picking_idsOne2many (stock.picking)All transfer operations
procurement_group_idMany2one (procurement.group)Procurement group for generated moves
route_idMany2one (stock.route)Common route for all requests

Counters

FieldTypeDescription
stock_request_countIntegerNumber of child requests
picking_countIntegerNumber of associated pickings

Workflow

Creating an Order

order = env['stock.request.order'].create({
    'expected_date': fields.Datetime.now(),
    'warehouse_id': warehouse.id,
    'location_id': location.id,
    'requested_by': env.user.id,
})

# Add stock requests
env['stock.request'].create({
    'order_id': order.id,
    'product_id': product1.id,
    'product_uom_id': product1.uom_id.id,
    'product_uom_qty': 5.0,
})

Confirming an Order

def action_confirm(self):
    if not self.stock_request_ids:
        raise UserError(
            _("There should be at least one request item for confirming the order.")
        )
    self.mapped("stock_request_ids").action_confirm()
    return True
Confirming an order confirms all child stock requests simultaneously (stock_request_order.py:300).
An order must have at least one child stock request before it can be confirmed.

State Transitions

Orders support the same actions as individual requests, but they cascade to all children:
order.action_confirm()
# Confirms all child stock requests

Route Management

Orders provide intelligent route computation based on all child requests:
@api.depends("warehouse_id", "location_id", "stock_request_ids")
def _compute_route_ids(self):
    # Computes available routes based on warehouse and location
    # Filters routes valid for the destination
    # If requests exist, finds common routes across all requests
(stock_request_order.py:150)

Route Synchronization

You can set a route on the order, and it will apply to all child requests:
@api.depends("stock_request_ids")
def _compute_route_id(self):
    for order in self:
        if order.stock_request_ids:
            first_route = order.stock_request_ids[0].route_id or False
            if any(r.route_id != first_route for r in order.stock_request_ids):
                first_route = False
            order.route_id = first_route

def _inverse_route_id(self):
    for order in self:
        if order.route_id:
            order.stock_request_ids.write({"route_id": order.route_id.id})
(stock_request_order.py:191)

Constraints and Validations

Stock Request Orders enforce these constraints:
  • Order names must be unique per company
  • Warehouse and location must belong to the same company
  • Only orders in draft state can be deleted
  • Child requests must have matching warehouse, location, expected date, and other key fields

Use Cases

Bulk Requests

Request multiple products for a project or department at once

Scheduled Deliveries

Group requests with the same expected delivery date

Location Restocking

Replenish multiple products at a specific location

Procurement Planning

Plan and manage procurement for multiple items together

View Stock Requests

def action_view_stock_requests(self):
    action = self.env["ir.actions.act_window"]._for_xml_id(
        "stock_request.action_stock_request_form"
    )
    if len(self.stock_request_ids) > 1:
        action["domain"] = [("order_id", "in", self.ids)]
    elif self.stock_request_ids:
        action["views"] = [
            (self.env.ref("stock_request.view_stock_request_form").id, "form")
        ]
        action["res_id"] = self.stock_request_ids.id
    return action
(stock_request_order.py:332)

View Transfers

def action_view_transfer(self):
    action = self.env["ir.actions.act_window"]._for_xml_id(
        "stock.action_picking_tree_all"
    )
    pickings = self.mapped("picking_ids")
    if len(pickings) > 1:
        action["domain"] = [("id", "in", pickings.ids)]
    elif pickings:
        action["views"] = [(self.env.ref("stock.view_picking_form").id, "form")]
        action["res_id"] = pickings.id
    return action
(stock_request_order.py:319)

Build docs developers (and LLMs) love