Material Request from Manufacturing Stock Entry Includes All Items Instead of Only Shortage Items

ERPNext Version

v16

Use Case

In the Manufacturing workflow, a Work Order is created and a “Material Transfer for Manufacture” Stock Entry is generated.

When creating a Material Request based on the required manufacturing materials, ERPNext currently includes all BOM items in the Material Request, regardless of whether sufficient stock is already available in the source warehouse.

Current Behavior

  • Item A: Required Qty = 10, Available Stock = 20 → Included in Material Request

  • Item B: Required Qty = 10, Available Stock = 0 → Included in Material Request

As a result, the Material Request contains both items.

Expected Behavior

Only items with stock shortages should be included in the Material Request.

Example:

  • Item A: Required Qty = 10, Available Stock = 20 → Should NOT be included

  • Item B: Required Qty = 10, Available Stock = 0 → Should be included with Qty = 10

The generated Material Request should contain only Item B.

Business Requirement

The goal is to generate purchase requests only for materials that are actually unavailable in stock, reducing manual effort and preventing unnecessary procurement requests.

Additional Question

Is there any standard ERPNext setting, Manufacturing configuration, Material Request option, or vanilla ERPNext functionality that can automatically create Material Requests only for shortage items?

If not available in standard ERPNext, what would be the recommended approach for implementing this requirement through customization?

Thank you for your guidance.

There is actually a standard ERPNext way to handle this it just requires using the right entry point.

Use the Work Order’s “Get Items for Material Request” instead of Stock Entry

From the Work Order directly, there is a button “Get Items for Material Request” (or via the Create button → Material Request). When triggered from the Work Order, ERPNext checks current stock availability against the required quantities and includes only items where required_qty > available_qty. This is the shortage-aware path.

The issue you’re seeing (all items included) happens specifically when a Material Request is generated from the Stock Entry itself, which doesn’t do a stock availability check — it just pulls all items from the BOM/Work Order.

Standard workflow that gives you shortage-only MR:

  1. Create Work Order
  2. Open the Work Order → Click Create → Material Request
  3. ERPNext will show a dialog, make sure “For Quantity” reflects the WO qty
  4. The generated MR will only contain items with insufficient stock in the source warehouse

Make sure the Source Warehouse is correctly set on the Work Order, ERPNext checks stock in that specific warehouse, so if it’s blank or wrong, it may not filter correctly.

If you still need to filter from Stock Entry (custom approach):
You can add a Server Script or override get_items to filter out rows where frappe.db.get_value('Bin', {'item_code': row.item_code, 'warehouse': row.s_warehouse}, 'actual_qty') >= row.qty. This gives you a clean shortage-only list programmatically.

Hope that helps!

Reviewed the ERPNext manufacturing workflow and verified the available actions in the Work Order form. As per the current system setup, the standard “Create → Material Request” option is not available in the Work Order.

Conducted R&D using ERPNext documentation and Frappe Forum discussions regarding shortage-based Material Request generation. Verified that Material Requests generated through the existing Stock Entry flow include all BOM items and do not perform stock availability filtering by default.

Analyzed the possibility of generating Material Requests only for shortage quantities and identified that a custom solution (Server Script or application customization) may be required to filter items based on available stock in the source warehouse.