Overview
The Stock Request framework extends the standard Odoostock.move model to integrate stock requests with inventory movements. This allows stock moves to be linked to stock request allocations and enables tracking of which stock requests are being fulfilled by specific moves.
Model Information
stock.move
stock.move
Fields
Stock Request Module
Links to stock request allocations associated with this move.
Computed field that returns all stock requests linked to this move through allocations.
Stock Return Request Module
Computes the quantity from this move that can still be returned. Takes into account already returned quantities from chained return moves.
Methods
Stock Request Module
Computes the stock_request_ids field by extracting all stock requests from the allocation_ids.Depends on:
allocation_idsExtends the base merge moves functionality to include allocation_ids when merging moves.Returns: Dictionary of fields to merge
Constraint method that validates the company of the stock request matches the company of the stock move.Constrains:
company_idRaises: ValidationError if companies don’t matchExtends copy functionality to duplicate allocation_ids when copying a stock move.Parameters:
default(dict, optional): Default values for the copy
Extends the cancel action to trigger stock request cancellation checks. Uses sudo to prevent ACL errors when users don’t have direct request permissions.Returns: Result from parent method
This method applies sudo to prevent ACL errors if the user doesn’t have permissions on stock requests (e.g., when canceling production moves).
Extends the done action to trigger stock request completion checks. Uses sudo to prevent ACL errors when users don’t have direct request permissions.Parameters:
cancel_backorder(bool): Whether to cancel the backorder
This method applies sudo to prevent ACL errors if the user doesn’t have permissions on stock requests (e.g., when completing production moves).
Stock Return Request Module
Computes the returnable quantity by looking at chained returned moves. Only processes moves that are not in draft or cancelled state.Logic:
- If the move has no returned_move_ids and is done, the full quantity is returnable
- Otherwise, returnable qty = original quantity - sum of returned quantities from chained returns
Computes the returnable quantity for a specific lot by analyzing chained returned moves.Parameters:
lot_id(recordset): The lot/serial number to checkqty(float, default=0): Starting quantity (used in recursion)
Extends the assign action to allow skipping automatic assignment when creating stock move lines manually.Context Variables:
skip_assign_move(bool): If True, skips the assignment
Set the
skip_assign_move context variable to True when you want to manually create stock move lines without automatic assignment.Usage Examples
Accessing Stock Requests from a Move
Checking Returnable Quantity
Creating Moves with Manual Line Assignment
Source Code References
- Stock Request extensions:
stock_request/models/stock_move.py - Stock Return Request extensions:
stock_return_request/models/stock_move.py
