Overview
Thestock.request.allocation model creates the connection between stock requests and stock moves. It tracks the quantity allocated from a request to a specific move, monitors completion status, and helps compute the overall progress of stock requests.
Model Name: stock.request.allocation
Fields
Relational Fields
Reference to
stock.request. The stock request being fulfilled.Properties: ondelete="cascade"Reference to
stock.move. The stock move fulfilling (part of) the request.Properties: ondelete="cascade"Reference to
res.company. The company this allocation belongs to.Related: stock_request_id.company_idProperties: readonly=True, store=TrueReference to
product.product. The product being allocated.Related: stock_request_id.product_idProperties: readonly=TrueReference to
uom.uom. The unit of measure for the product.Related: stock_request_id.product_uom_idProperties: readonly=TrueQuantity Fields
Quantity of the stock request allocated to the stock move, in the UoM of the Stock Request.This is the quantity that was originally requested from this allocation.
Quantity of the stock request allocated to the stock move, in the default UoM of the product.Properties:
compute="_compute_requested_product_qty"This is the converted quantity in the product’s base UoM.Quantity of the stock request allocated to the stock move, in the default UoM of the product.Properties:
copy=FalseThis represents the actual quantity that has been allocated/processed.Remaining open quantity that hasn’t been fulfilled yet.Properties:
compute="_compute_open_product_qty"Calculated as: requested_product_qty - allocated_product_qty (when move is not cancelled or done)Methods
Compute Methods
Converts the requested quantity from the request’s UoM to the product’s default UoM.Depends on:
stock_request_id.product_idstock_request_id.product_uom_idrequested_product_uom_qty
- Uses UoM conversion with
HALF-UProunding method - Converts from
product_uom_idtoproduct_id.uom_id
stock_request/models/stock_request_allocation.py:64
Calculates the remaining open quantity for this allocation.Depends on:
requested_product_qtyallocated_product_qtystock_move_idstock_move_id.state
- Returns
0.0if the stock move is in statecancelordone - Otherwise returns
requested_product_qty - allocated_product_qty(minimum 0)
stock_request/models/stock_request_allocation.py:77
Field Details
Quantity Field Relationships
The allocation model tracks quantities at different stages:State-Dependent Behavior
Theopen_product_qty field behaves differently based on the stock move state:
Usage in Stock Request Flow
Creation
Allocations are typically created during procurement rule execution:Tracking Progress
The stock request uses allocations to compute its progress:Computing Stock Moves
Allocations link to stock moves for viewing:Data Model
Cascade Deletion
Related Fields
Several fields arerelated to the stock request:
company_id→stock_request_id.company_id(stored)product_id→stock_request_id.product_idproduct_uom_id→stock_request_id.product_uom_id
Usage Example
Integration Points
With stock.request
- Referenced via
allocation_idsOne2many field - Used in
_compute_qty()to calculate progress - Used in
_compute_move_ids()to find related moves - Created in
_prepare_stock_request_allocation()and_action_use_stock_available()
With stock.move
- Extended via
stock_request_idscomputed field (seestock_move.py) - Move state changes affect
open_product_qtycomputation - Move cancellation sets open quantity to zero
With Procurement
- Created when procurement rules generate stock moves
- Links the procurement back to the originating request
- Enables tracking from request → procurement → move → picking
See Also
- stock.request - The main stock request model
- stock.request.order - Parent order grouping requests
- stock.request.abstract - Base abstract model
