Inventory and warehouse operations
Inventory and warehouse operations define what stock exists, where it is held, how it moves, and how its quantity, value, and history stay linked. Item and warehouse masters set the rules. Stock movements then connect supply, production, fulfillment, accounting, replenishment, and reporting.
Operating model
Item masters
The Item master defines the stock identity and the rules that other business flows use. It states whether the item is held in stock, which units can represent it, how it is valued, whether it needs serial or batch tracking, and where replenishment starts.
An item can be a stock item or a non-stock item. Stock items create quantity history. Non-stock items can still appear in business documents but do not create the same warehouse balance. Item templates and variants let a common product definition produce distinct stock identities. Once stock or linked transactions exist, key item properties such as stock status, stock unit, tracking mode, and some valuation choices are protected so that old history remains meaningful.
Item defaults carry company and warehouse context into transactions. Unit conversion and price context then let a document use a buying or selling unit while stock remains measured in the stock unit. Reorder rows connect the item to warehouse-level thresholds and supply types.
Key item choices include:
- Stock or non-stock use.
- Stock, purchase, and sales units with conversion rules.
- FIFO, Moving Average, LIFO, or Standard Cost valuation.
- Serial or batch tracking with expiry and sample rules.
- Company-specific defaults and warehouse reorder rules.
- Variant attributes, supplier data, customer codes, and barcodes.
References: erpnext/…/item.py• L234-278 erpnext/…/item.py• L1226-1337 erpnext/…/test_item.py• L980-1012
Warehouse masters
The Warehouse master defines a stock location within a company. Warehouses form a tree so users can work at a physical location and report at a site or group level without treating the group as a separate store.
A warehouse can be a ledger location or a group node. Its company, parent, type, transit role, and inventory account control which movements and reports can use it. Warehouse changes must preserve these links and the stock history already recorded against the location.
References: erpnext/…/warehouse.py• L53-105 erpnext/…/warehouse.py• L113-219 erpnext/…/warehouse_wise_stock_balance.py• L30-90
Inventory dimensions
Inventory dimensions add a stock boundary beyond item and warehouse. They let the business split stock by a meaningful field without creating a new item or warehouse for every value.
The dimension rules decide which inventory documents use the boundary and can apply a separate negative-stock check for each value. After stock history exists, the fields that define the dimension are protected so later changes do not break the stock view.
References: erpnext/…/inventory_dimension.py• L49-104 erpnext/…/inventory_dimension.py• L137-169 erpnext/…/stock_ledger_entry.py• L116-217
Stock movement lifecycle
Movement records
Stock movements turn a physical event into a shared business record. Stock Entry supports receipts, issues, transfers, manufacturing, repacking, disassembly, subcontracting, customer-provided stock, and returns. Its purpose selects the rules for the event and its links identify the source demand or supply.
The system validates the item, company, warehouse direction, quantity, UOM, tracked identities, quality requirements, and source-document limits before submission. A submitted movement updates stock history and then updates the connected reservation, order, production, subcontracting, quality, and accounting state. Cancellation reverses those effects rather than removing the history.
When a movement uses a Work Order, its state and allowed alternatives control what can be transferred or consumed. Manufacturing entries connect raw materials, finished goods, process loss, and secondary output to production progress. Subcontracting entries keep supplied and returned material within the linked order. Transfers can use a transit warehouse so the sending and receiving legs remain separate until receipt.
References: erpnext/…/stock_entry.py• L249-278 erpnext/…/stock_entry.py• L363-437 erpnext/…/stock_entry.py• L520-547 erpnext/…/stock_entry_base.py• L44-127 erpnext/…/subcontracting.py• L15-107
Movement flow
The movement flow shows how a supply or demand need becomes a checked stock event and then updates quantity, value, and downstream status.
flowchart LR
Need[Supply or demand need] --> Source[Source document or Work Order]
Source --> Reserve[Optional reservation]
Source --> Plan[Material Request or planned movement]
Reserve --> Pick[Pick, issue, transfer, or deliver]
Plan --> Receive[Purchase receipt or production receipt]
Pick --> Check[Quality and stock checks]
Receive --> Check
Check --> Post[Submitted stock movement]
Post --> Ledger[Quantity and value history]
Post --> Links[Order, reservation, production, and accounting status]
Ledger --> Reports[Balance, value, age, and trace reports]
Stock Entry uses source and target warehouses to express the direction of each row. A transit transfer posts the first leg to the transit location and creates a linked receiving entry for the remaining quantity. Unit conversion keeps the source quantity, transit quantity, and receiving remainder comparable in the stock UOM.
References: erpnext/…/stock_entry.py• L658-728 erpnext/…/material_transfer.py• L23-220 erpnext/…/stock_entry.js• L341-365 erpnext/…/test_stock_entry.py• L300-462
Manufacturing operations
Manufacturing stock movements consume material and create finished or secondary stock against a BOM, Work Order, or Job Card. The process uses the production quantity and the selected material-consumption policy to determine what remains to consume and what output can be posted.
The movement checks production progress, component quantities, process loss, alternative items, and tracked finished-good identities. It also keeps transferred material in work in progress distinct from material already consumed. This prevents a later manufacture entry from consuming more than the Work Order supplied or creating output outside the allowed production state.
Repack uses the same stock movement model to convert consumed stock into one or more outputs. Disassembly reverses a prior production result and derives its rows from the source manufacture or Work Order, so it cannot create unsupported component stock.
References: erpnext/…/manufacturing.py• L276-365 erpnext/…/manufacturing.py• L402-521 erpnext/…/manufacturing.py• L580-607 erpnext/…/stock_entry.py• L1339-1415 erpnext/…/stock_entry.js• L370-420
Receipts and fulfillment
Receipts add purchased, manufactured, returned, or customer-provided goods to a warehouse. Fulfillment issues or transfers goods for a customer or another internal demand. Both flows use the same stock controls for warehouse availability, UOM, quality, serial and batch identity, and source-document quantity.
Putaway chooses a valid destination without changing the nature of the receipt. Quality Inspection can act as a gate when the item or movement requires an accepted result. Pick Lists and reservations protect planned demand before the final movement, but they do not increase on-hand stock.
The sales fulfillment page explains the customer-facing order, pick, delivery, and return flow. Inventory supplies the quantities and tracked identities that this flow consumes. Returns use the original movement context so quantity, identity, and valuation remain tied to the goods that were delivered or received.
References: erpnext/…/stock_entry.js• L169-218 erpnext/…/stock_entry.js• L1285-1333 erpnext/…/pick_list.py• L110-215 erpnext/…/quality_inspection_service.py• L84-163
Valuation and stock control
Valuation basis
Inventory valuation assigns a cost to the quantity held at each stock location. FIFO, Moving Average, LIFO, and Standard Cost provide different rules for carrying incoming cost into stock and outgoing cost out of stock.
Serialized items can keep cost per unit when serial-wise valuation is enabled before serial history exists. If it is disabled, the item uses Moving Average because earlier per-unit costs cannot be replayed as another layer model. Standard Cost uses an effective item-and-company rate and sends the difference between actual or derived cost and standard value to a variance account.
Additional costs on a Stock Entry and landed costs on a receipt increase the value assigned to incoming stock. The allocation also reaches the accounting view. A landed cost voucher must point to a submitted stock-affecting receipt or to a Manufacture or Repack entry in the same company. A later cost change can require stock and accounting reposting.
The stock valuation and reposting page covers valuation rules, Standard Cost history, back-dated changes, comparison, adjustment entries, and reposting in more detail.
References: erpnext/…/item.py• L1226-1337 erpnext/…/stock_entry.py• L722-775 erpnext/…/gl_composer.py• L25-124 erpnext/…/landed_cost_voucher.py• L134-183 erpnext/…/landed_cost_voucher.py• L525-568
Stock ledger
The stock ledger is the ordered history of item quantity and value by warehouse. Each movement records its source, quantity change, resulting balance, rate, value, and serial or batch link so reports can show both the current result and the path to that result.
Submission posts source legs and target legs in a controlled order. Cancellation posts the reverse effect. A change to an earlier movement can make later balances or cost layers stale, so reposting recalculates the affected future history within stock and accounting closing limits.
References: erpnext/…/stock_entry.py• L1416-1446 erpnext/…/stock_ledger.py• L44-185 erpnext/…/stock_ledger.py• L236-313 erpnext/…/repost_item_valuation.py• L47-179
Reconciliation and adjustment
Stock Reconciliation is the controlled path for aligning recorded stock with a counted balance or for creating opening stock. It changes the recorded quantity, identities, or value; it does not represent consumption.
An explicit zero rate means a real value change. A blank rate keeps the current value. Serialized and batched counts use identity bundles, while a closing entry protects history before its completed date. Reorder and consumption views exclude reconciliation legs so a count or revaluation does not appear as demand.
References: erpnext/…/stock_reconciliation.py• L83-167 erpnext/…/stock_reconciliation.py• L295-357 erpnext/…/stock_reconciliation.py• L716-816 erpnext/…/stock_closing_entry.py• L38-64
Serial and batch traceability
Serial identity
A serial number identifies one unit of an item. Serial history follows that unit through warehouses, movements, customer or employee assignment, warranty, maintenance, assets, and returns.
Serial tracking is an item choice. The system keeps one physical serial number tied to one item and blocks changes that would make existing serial or bundle history ambiguous. Missing or mismatched serials cannot be used to silently create a different unit during a stock movement.
References: erpnext/…/serial_no.py• L30-108 erpnext/…/serial_no.py• L204-248 erpnext/…/item.py• L1295-1355 erpnext/…/serial_batch_identity.py• L18-70
Batch identity
A batch identifies a group of units with a shared source or production context. Batch history supports quantity, expiry, supplier or source links, sample retention, and optional batch-level valuation.
Batch operations can split a parent batch into child batches while keeping the source relationship. The available quantity and expiry view then stays linked to the stock movement history rather than becoming a separate balance source.
References: erpnext/…/batch.py• L161-255 erpnext/…/batch.py• L269-413 erpnext/…/manufacturing.py• L222-274 erpnext/…/stock_entry.js• L71-101
Serial and batch bundles
A Serial and Batch Bundle is the trace record for the identities used by one stock movement. It connects the item, warehouse, direction, quantity, rate, and source voucher.
The bundle gives receipts, picks, deliveries, manufacturing, disassembly, transfers, and returns one common identity view. It can select outgoing stock by configured order or reservation. A submitted movement bundle is fixed and remains the source for identity quantity and valuation replay. Reservation-only bundles stay separate from posted stock.
Manufacturing can map consumed serials or batches to the finished-good serial or batch that received them. This supports forward and backward trace without changing the posted quantity.
References: erpnext/…/stock_entry.py• L420-435 erpnext/…/stock_entry.js• L634-806 erpnext/…/manufacturing.py• L240-274 erpnext/…/test_stock_entry.py• L764-866
Traceability reporting
Traceability reporting answers where tracked stock came from and where it went. Backward tracing follows finished goods to source material. Forward tracing follows received or produced stock into later movements and deliveries.
The inventory replenishment and traceability page covers detailed trace and replenishment workflows. Batch and serial reports distinguish posted movement history from reservation data so current stock is not overstated.
References: erpnext/…/serial_no_and_batch_traceability.py• L35-127 erpnext/…/serial_and_batch_summary.py• L25-95 erpnext/…/available_batch_report.py• L72-190 erpnext/…/batch_wise_balance_history.py• L23-145
Replenishment and fulfillment supply
Reorder planning
Replenishment compares projected stock with warehouse-level reorder rules. An Item Reorder row defines the location that needs stock, the scope used to check supply, the threshold, the quantity to add, and the Material Request type.
Projected quantity combines current stock with open demand and supply. When it reaches the configured reorder point, the system can create supply for purchase, transfer, issue, manufacture, subcontracting, or customer-provided stock. Unit conversion keeps requested, ordered, received, and transferred quantities comparable.
The inventory replenishment and traceability page explains this planning workflow and its trace links in more detail.
References: erpnext/…/item.py• L652-690 erpnext/…/stock_projected_qty.py• L18-90 erpnext/…/items_to_be_requested.py• L17-61 erpnext/…/material_transfer.py• L604-707
Reservations
A stock reservation holds a quantity or named serial and batch identities for planned demand before the final issue or delivery. It protects that demand from competing picks while the physical stock remains in its warehouse.
Reservations track the change from available to reserved, delivered, transferred, consumed, or cancelled. Delivery, manufacturing, subcontracting, transfer, and cancellation update the reservation so the held supply is not silently lost. A reservation bundle is a planning record, not a posted stock movement.
References: erpnext/…/stock_reservation_entry.py• L79-149 erpnext/…/stock_reservation_entry.py• L151-341 erpnext/…/stock_entry.py• L524-539 erpnext/…/manufacturing.py• L878-914
Supply handoff
Material Request is the handoff from a stock need to a supply action. It carries the item, quantity, required date, warehouse context, and supply type into purchase, transfer, issue, manufacture, subcontracting, or customer-provided work.
Later documents update the request with ordered, received, and transferred quantity. A transfer can be direct or can use an in-transit warehouse. The same source links keep partial supply visible until the request is complete.
References: erpnext/…/material_request.py• L171-212 erpnext/…/material_request.py• L296-470 erpnext/…/material_transfer.py• L604-707 erpnext/…/stock_entry.js• L453-499
Stock reporting
Balance and movement views
Stock Balance shows quantity and value by item and warehouse for a selected period. Stock Ledger explains the movements behind that result. Warehouse-wise views roll child locations into parent groups for site-level review.
These views use submitted, non-cancelled stock history and can apply company, item, warehouse, date, and dimension scope. Projected quantity adds open demand, supply, and reservation signals. Pick and reservation records do not add on-hand stock because they describe planned use rather than a warehouse movement.
References: erpnext/…/stock_balance.py• L49-170 erpnext/…/stock_ledger.py• L22-152 erpnext/…/warehouse_wise_stock_balance.py• L30-90 erpnext/…/stock_projected_qty.py• L45-90
Serial and batch balance views
Serial and Batch Wise Stock Balance extends the item-and-warehouse view with the tracked identities still in stock. It combines movement history with bundle identity data so a user can compare a balance with physical serials or batches.
Batch balance history adds opening quantity, receipts, issues, value, and current reserved quantity for a date range. Large history views need a bounded item or warehouse scope to remain useful.
References: erpnext/…/serial_and_batch_wise_stock_balance.py• L17-160 erpnext/…/batch_wise_balance_history.py• L23-145 erpnext/…/serial_and_batch_summary.py• L25-95
Age and value views
Age and value reports show how long stock has remained and how much value sits in each age group. They combine balance results with the valuation basis so users can find old, slow-moving, or high-value stock.
FIFO and LIFO age the remaining stock by their layer order. Moving Average uses the current average rate. Batch-wise valuation keeps value with the batch. A transfer starts the stock age in the new warehouse at the transfer event.
References: erpnext/…/stock_ageing.py• L35-127 erpnext/…/stock_ageing.py• L289-396 erpnext/…/warehouse_wise_item_balance_age_and_value.py• L24-87
Integrity checks
Inventory checks compare stock history with identity and account views. They can show mismatches between quantity and serial count, quantity and batch quantity, stock value and account value, or movement rows and their bundles.
These checks point to an area that needs review. They do not replace reconciliation or create a new balance source. Valuation comparison separately checks quantity, rate, and value against an independent replay.
References: erpnext/…/stock_qty_vs_serial_no_count.py• L29-85 erpnext/…/stock_qty_vs_batch_qty.py• L22-99 erpnext/…/stock_and_account_value_comparison.py• L18-63 erpnext/…/stock_ledger_invariant_check.py• L42-158 erpnext/…/stock_valuation_comparison.py• L47-121
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to Item stock status, UOM, valuation, Standard Cost, serial or batch rules, company defaults, or reorder rows can change movement, pricing, production, and replenishment behavior.
- Changes to item merge or variant rules must preserve stock identity, existing reservations, linked production demand, and serial or batch uniqueness.
- Changes to Stock Entry purposes or purpose handlers must preserve source and target direction, Work Order limits, alternative-item rules, transit handoff, reservations, tracked identities, ledger posting, accounting, and linked status.
- Changes to manufacturing costing must keep consumed material, process loss, secondary output, additional costs, landed costs, and Standard Cost variance aligned.
- Changes to transfer quantity or UOM conversion must keep direct transfers, transit receipts, partial receipts, source-row progress, and Material Request status aligned in stock UOM.
- Changes to subcontracting checks must preserve the link between supplied, returned, consumed, reserved, and ordered quantity.
- Changes to landed costs must preserve submitted receipt scope, company scope, item-row links, account dimensions, charge allocation, serial rates, and future reposting.
- Changes to serial and batch bundle handling must keep identity quantity, valuation, reservation data, return links, and trace mappings separate between draft, submitted, cancelled, and reservation records.
- Changes to reporting must preserve the difference between posted stock, reserved stock, projected stock, warehouse-tree rollup, and identity history.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Serial-wise valuation is enabled after serial records exist | Outward stock cannot use a complete per-unit cost history | Enable it before serial records exist |
| A tracked item changes to non-serialized while active bundles exist | Existing identity links become ambiguous | Delete or cancel the active bundles first |
| A Stock Entry uses a stopped, closed, or unsubmitted Work Order | The movement is rejected or can exceed valid production state | Check Work Order state and use the linked purpose |
| A transit transfer targets a normal warehouse | The two-leg transfer cannot preserve transit status | Use a Transit warehouse for the first target |
| A transfer exceeds the source row or Material Request quantity | Source progress and received quantity become inconsistent | Validate linked source quantity in stock UOM |
| A landed cost voucher uses an unsubmitted or non-stock receipt | Intended stock value is not updated | Link it to a submitted stock-affecting receipt or Manufacture/Repack entry in the same company |
| A Standard Cost movement carries a different actual cost | Stock value and expense variance do not agree | Use the configured variance account and preserve the standard rate |
| A required inspection is missing or rejected | Receipt, issue, transfer, delivery, or output can stop | Apply the item and movement inspection rule before submission |
| A reservation bundle is counted as posted stock | On-hand quantity and identity reports are overstated | Keep reservation data out of physical stock totals |
| A submitted movement bundle is edited | Identity quantity and valuation replay can diverge from the ledger | Treat submitted bundles as fixed |
| A back-dated movement changes an earlier cost layer | Later stock and accounting results become stale | Repost the affected future history within closing limits |
| A disassembly or manufacture row does not match its source | The movement can create unsupported component or output stock | Derive and validate quantities from the source Work Order or manufacture entry |
Key files
| File | Why to read it |
|---|---|
| erpnext/…/item.py | Defines stock identity, UOM, valuation, tracking, defaults, variants, and reorder behavior. |
| erpnext/…/test_item.py | Shows the business guarantees for item changes, merges, variants, UOMs, and stock links. |
| erpnext/…/warehouse.py | Defines warehouse ownership, hierarchy, and location rules. |
| erpnext/…/stock_entry.py | Coordinates movement purposes, validation, reservations, stock ledger, accounting, and linked documents. |
| erpnext/…/stock_entry.js | Shows the user flow for warehouses, UOMs, tracked identities, transit, BOMs, and source documents. |
| erpnext/…/stock_entry_base.py | Defines shared Work Order and alternative-item rules. |
| erpnext/…/material_transfer.py | Defines warehouse transfers, transit receipt progress, Material Request handoff, and manufacturing material transfer. |
| erpnext/…/manufacturing.py | Defines material consumption, production output, process loss, alternatives, and tracked manufacturing stock. |
| erpnext/…/subcontracting.py | Defines material supplied to and returned from subcontractors. |
| erpnext/…/gl_composer.py | Connects Stock Entry value, additional costs, landed costs, and Standard Cost variances to accounting. |
| erpnext/…/landed_cost_voucher.py | Defines how receipt and production costs are allocated back to stock value. |
| erpnext/…/stock_ledger.py | Maintains ordered stock quantity and value history. |
| erpnext/…/serial_and_batch_bundle.py | Defines the shared identity record for serial and batch movement history. |
| erpnext/…/stock_reservation_entry.py | Defines reserved supply before the final stock movement. |
| erpnext/…/material_request.py | Connects projected need with later supply actions. |
| erpnext/…/stock_balance.py | Shows how posted stock history becomes balance and value views. |
| erpnext/…/serial_no_and_batch_traceability.py | Shows how serial and batch history answers source and destination questions. |
| erpnext/…/stock_ageing.py | Shows how valuation layers become age and value views. |