Track stock by inventory dimensions
ERPNext tracks stock by Item, warehouse, batch, and serial number. An inventory dimension adds one more way to track it, for example by shelf, pallet, or project. ERPNext adds a field for the dimension to stock documents and records its value in the stock ledger. You can then filter the Stock Ledger and Stock Balance reports by that dimension.
Prerequisites
- A DocType that holds the values of the dimension. For example, to track shelves, create a Shelf DocType with one document for each shelf. You can use any DocType that is not a child table.
Create an inventory dimension
- Open the Inventory Dimension list and select Add Inventory Dimension.
- In Reference Document, select the DocType that holds the values, for example Shelf. You cannot select a child table, or Batch, Serial No, Warehouse, or Item.
- Enter the Dimension Name. ERPNext uses it as the label of the new field.
- Choose where the dimension applies, in the Applicable For tab:
- Keep Apply to All Inventory Documents selected to add the field to every document that has a Batch No or Serial No field.
- Or clear it and select one DocType in Apply to Document. See Apply a dimension to one document.
- Optionally, set these fields:
- Fetch Value From: a field on the parent form. ERPNext copies its value into the dimension of every row. See Fetch the value from the parent form.
- Validate Negative Stock: blocks transactions that take the stock of a dimension value below zero in a warehouse.
- Mandatory: makes the dimension required in transactions.
- Mandatory Depends On (Backend): shown when Mandatory is clear. A Python expression. When it is true, the dimension becomes required. For example,
doc.t_warehouse and doc.qty > 0.
- Save the inventory dimension. ERPNext creates the custom fields.

Apply a dimension to one document
When Apply to All Inventory Documents is clear, these fields appear:
| Field | Description |
|---|---|
| Apply to Document | The DocType that gets the dimension field, for example Stock Entry Detail. |
| Conditional Rule | An expression that decides when the dimension applies. For a child table, use parent.fieldname for the parent form and doc.fieldname for the row. For example, parent.doctype == "Stock Entry" and doc.item_code == "Test". |
| Type of Transaction | Inward, Outward, or Both: the stock movements to which the dimension applies. |
For example, you can create a "From Shelf" dimension that applies to outward movements, and a "To Shelf" dimension that applies to inward movements.
Fetch the value from the parent form
A Purchase Receipt can have hundreds of rows on the same shelf. Instead of setting the shelf on every row, add a Shelf custom field to the Purchase Receipt form. Then select that field in Fetch Value From. ERPNext applies the shelf value from the form to the stock ledger entries of all rows, even when a row has no value.
Use the dimension in transactions
ERPNext adds an Inventory Dimension section to the Item rows of each applicable document. Select the dimension value in each row. When you submit the document, ERPNext saves the value in the stock ledger entries.
Some documents get two fields for one dimension, because stock moves from one value to another. For a dimension named "Shelf":
| Document rows | Fields |
|---|---|
| Stock Entry | Source Shelf (when a source warehouse is set) and Target Shelf (when a target warehouse is set) |
| Purchase Receipt, Purchase Invoice | Target Shelf, Rejected Shelf, and Source Shelf for an internal supplier |
| Delivery Note, Sales Invoice | Source Shelf, and Target Shelf for an internal customer |

View stock by dimension
The Stock Ledger and Stock Balance reports have a filter for each inventory dimension. Use it to see the quantity for each dimension value. Learn more about the Stock Ledger report.
Change or delete a dimension
After stock transactions exist for a dimension, you can change only Fetch Value From, Type of Transaction, Conditional Rule, and Validate Negative Stock. When you delete a dimension, ERPNext deletes its custom fields.
Limits
- ERPNext does not keep a separate valuation rate for each dimension value.
- In a Stock Reconciliation, you can use inventory dimensions only to enter opening stock. You cannot use them to change the quantity or the valuation rate of existing stock. Learn how to enter opening stock.
Troubleshooting
| Message | Cause | Fix |
|---|---|---|
qty units of item are required in warehouse with the inventory dimension: value ... to complete the transaction. | Validate Negative Stock is selected and the dimension value does not have enough stock. | Receive or transfer stock into that dimension value first, or select another value. |
Row #n: You cannot use the inventory dimension 'dimension' in Stock Reconciliation to modify the quantity or valuation rate. | A Stock Reconciliation row with a dimension changes existing stock. | Use a Stock Entry to move stock between dimension values. |
The reference document doctype can not be child table. | Reference Document is a child table. | Select a DocType that is not a child table. |
The user can not change value of the field field because stock transactions exists against the dimension | You changed a locked field after transactions. | Create a new dimension instead. |