Skip to main content

Manufacturing & distribution

How to Handle Unfulfilled SO Quantities in ERPNext Production Planning

ERPNext Production Plan skips Sales Orders or shows the wrong pending quantity after partial production. The fields that decide it, and how to fix them.

Updated 12 Oct 202610 min readBy ManojFirst published 4 Aug 2026

You have open Sales Orders, some partly produced and partly delivered. You open a Production Plan, get the Sales Orders and their items, and expect the quantities still to be made. Instead some orders don't appear, and others show nothing pending although a Work Order fell short through rejection or scrap. ERPNext decides this from counters on the Sales Order Item, and they count what was planned or ordered for production, not what was made. This guide shows which counters decide what, how to check them, and how to re-plan the shortfall.

Production planning with partial production is where ERPNext's manufacturing module has its roughest edges. The Production Plan pulls Sales Orders and their pending quantities from counters on the Sales Order Item, and those counters move when a plan or a Work Order is made, not when the goods are. I am Manoj, and I lead ERPNext and Frappe implementations at MithTech, a team of Frappe specialists in Bengaluru. Re-planning a shortfall is one of the questions manufacturing clients raise once they run real volumes.

Why does "Get Items" show the wrong quantity?

A Production Plan built from Sales Orders works in two steps, and each reads a different counter on the Sales Order Item. In ERPNext v15:

Get Sales Orders:  list the order while  so_item.qty > so_item.production_plan_qty
Get Items:         pending_qty = so_item.qty - max(so_item.work_order_qty, so_item.delivered_qty)

That gives three ways for the plan to come out wrong:

1. The counter already covers a shortfall. production_plan_qty rises when a plan is submitted and work_order_qty when a Work Order is made. Neither falls back when the Work Order produces less than planned. If a Work Order for 30,000 made 29,000, the order still looks fully covered and the missing 1,000 is not offered to the next plan. When several Sales Orders are combined into one Work Order, the link back to each order can be lost as well, so its produced quantity isn't updated (forum thread 163260).

2. A filter on the plan excludes the order. Stopped and Closed orders never appear. If you set a Sales Order status, customer, project, item or date filter on the plan, orders outside it are left out. Check the filters before you suspect the data.

3. No active BOM. Items are returned only when a BOM with is_active = 1 exists for them. This happens when a BOM is deactivated during an engineering change, or a new version is made but not submitted.

How do you see the gap?

The Fulfillment Gap Calculator breaks a Sales Order quantity into its parts: what has been delivered, what is in production, what can be planned with the material you have, and what is blocked.

Calculator

Fulfillment Gap Calculator

Enter your SO quantity, delivered, in-production, and material availability to see the exact breakdown of what can and cannot be planned for production.

Unfulfilled Qty250500 - 150 delivered - 100 in prod
Can Be Planned18072% of 250 has material
Blocked by Material70Needs procurement before planning
Production Plan Summary
  • Create Production Plan for 180 units (material available)
  • Create Material Request for the remaining 70 units (shortage)
  • Already in production: 100 | Delivered: 150

How do you diagnose your case?

The Production Plan Debugger walks through the checkpoints. Answer each question about your Sales Order and it points to the cause that applies.

Interactive

Production Plan Debugger

Diagnostic checks to identify why Get Items from Sales Orders shows wrong or zero pending quantities. Each check explains what to look for and what the fix is.

Step 1GitHub #49819

SO has pending qty?

Check if qty_to_deliver > 0 on the Sales Order Item. If all quantities are already delivered, the SO won't appear in "Get Items".

Step 2Forum #163193

SO status is 'To Deliver and Bill' or 'To Deliver'?

Production Plan > Get Items only picks SOs with status that indicates pending delivery. Statuses like 'Completed', 'Cancelled', or 'Closed' are excluded.

Step 3

Item has an active default BOM?

Production Plan only picks items that have a BOM marked as both 'Is Active' and 'Is Default'. Without one, the item is treated as a purchase item.

Step 4Forum #161593

Warehouse filter matches?

If you set a warehouse filter on the Production Plan, only SO Items with a matching delivery warehouse appear. A mismatch means zero items.

Step 5GitHub #50809

Previously planned qty accounted for?

The production_plan_qty field on SO Items tracks how many units are already in a submitted Production Plan. If this value is stale or wrong, Get Items may under-count or skip items.

What is the fix?

The fix depends on the cause. The recipe below has scripts to query unfulfilled Sales Order items directly, to compare the counters with what was planned, and to check material availability. Read them against the two formulas above before you run anything that writes to Sales Order Items, and try them on a copy of your site first.

Code recipe

Production Plan Fix Recipe

Python recipe: query unfulfilled SO items with pending qty and an active BOM, compare the planning counters against actual Production Plan and Work Order records, and check raw material availability against BOM requirements.

Fetch Sales Order items with pending quantities and active BOMs, ready for production planning. Handles the partial-delivery edge case that trips up the standard Get Items button.

python
# Fetch Sales Orders with unfulfilled quantities
# for production planning in ERPNext v15
# See: GitHub #49819, Forum #163193

import frappe

def get_unfulfilled_so_items(
    company: str,
    from_date: str | None = None,
    item_code: str | None = None,
):
    """Return SO items where qty_to_deliver > 0
    and an active BOM exists for the item."""

    filters = {
        "docstatus": 1,
        "company": company,
        "status": ["not in", ["Completed", "Cancelled", "Closed"]],
    }
    if from_date:
        filters["transaction_date"] = [">=", from_date]

    orders = frappe.get_all(
        "Sales Order",
        filters=filters,
        fields=["name"],
    )

    items = []
    for so in orders:
        so_items = frappe.get_all(
            "Sales Order Item",
            filters={
                "parent": so.name,
                "qty": [">", 0],
            },
            fields=[
                "item_code", "qty", "delivered_qty",
                "produced_qty", "work_order_qty",
            ],
        )
        for item in so_items:
            # Get Items pending = qty - max(work_order_qty, delivered_qty)
            pending = item.qty - max(item.work_order_qty, item.delivered_qty)
            if pending <= 0:
                continue
            if item_code and item.item_code != item_code:
                continue
            # Check for active BOM
            bom = frappe.db.exists(
                "BOM",
                {"item": item.item_code, "is_active": 1, "is_default": 1},
            )
            if not bom:
                continue
            items.append({
                "sales_order": so.name,
                "item_code": item.item_code,
                "so_qty": item.qty,
                "delivered_qty": item.delivered_qty,
                "produced_qty": item.produced_qty,
                "pending_qty": pending,
                "bom": bom,
            })

    return items

0 of 4 steps done

Tick a step’s number when it is done; the ticks stay on this device.

List what is really unfulfilled

From the bench console, list each open Sales Order Item with its qty, delivered_qty, production_plan_qty and work_order_qty, and the produced quantity of the Work Orders linked to it. Where the produced quantity is below work_order_qty, you have a shortfall the plan can't see.

Decide how to plan the shortfall

Don't edit the counters by hand as a habit: they are maintained by ERPNext and a manual change is overwritten or breaks the link to the documents. For a one-off shortfall, raise a Work Order for the missing quantity (with the Sales Order reference in the remarks), or plan that item without the Sales Order. If shortfalls are routine, agree a standard way with whoever owns your ERPNext instance, and test it on a copy first.

Check material availability

For each item you plan to make, check raw material stock in the source warehouse against the BOM for the quantity. That tells you what can run now and what needs a Material Request first.

Create the Work Orders

Create Work Orders for the quantity you can make, and Material Requests for what is blocked. Note the reason for any shortfall Work Order, so the next person can follow why an order has more than one.

What does the planning workflow look like, with its failure points?

The flow below shows the path from Sales Order to delivery, with the points where production planning goes wrong.

Interactive

Planning Workflow Diagram

Click through each step of the production planning workflow to see what can go wrong, from SO to Get Items to BOM check to material availability to Work Order completion to delivery.

Sales Order

The starting point. A submitted Sales Order with pending delivery quantity. If status is Completed/Cancelled/Closed, it won't appear in Production Plan.

What should you know before you change anything?

Test on a copy first. Any script that writes to Sales Order Items changes records that other documents depend on. Run it on a copy of the site, compare the results, and only then on production, outside working hours.

Material availability is point-in-time. A stock check reads current stock. Between the check and Work Order creation, other plans, purchase receipts and stock entries move it. Run the check just before you create Work Orders.

Multi-level BOMs. After getting items, "Get Sub Assembly Items" explodes the BOMs and adds the sub-assemblies to make. The counters above sit on the top-level Sales Order Item, so the shortfall question is asked there.

Likely cause
Get Items shows 0 after a Work Order fell shortwork_order_qty counts the full Work Order, not what it madePlan the shortfall with its own Work Order and a note
Sales Order not listed by Get Sales Ordersproduction_plan_qty already equals qty, or a plan filter excludes itCheck the plan's filters, then the counter
Item does not appear in Get Items at allNo active BOM for the itemSubmit or re-activate the BOM
Sales Order never appearsOrder is Stopped or ClosedRe-open the order if it is still live
Pending quantity lower than expected after a deliverydelivered_qty is larger than work_order_qty, so delivery sets the pending figureCheck deliveries made from stock against the order

Production Plan symptoms, causes and fixes (ERPNext v15)

At a glance

AspectWhat to know
Is the Sales Order listed?Only while an item's qty is above its production_plan_qty, and the order is not Stopped or Closed
Pending quantity on Get Itemsqty - max(work_order_qty, delivered_qty)
BOMThe item needs an active BOM
The usual trapA Work Order that made less than planned still counts in full

Frequently asked questions

Why does ERPNext Production Plan show zero pending quantity for my Sales Order?

Because the pending quantity is qty - max(work_order_qty, delivered_qty) on the Sales Order Item, and work_order_qty counts what Work Orders were made for, not what they produced. If a Work Order fell short, the order still looks fully covered. Plan the shortfall with its own Work Order and a note of why.

How do I get items from partially delivered Sales Orders in ERPNext?

Use the Production Plan: get the Sales Orders, then get the items. An order is listed while an item's quantity is above its production_plan_qty, and each item's pending quantity is its quantity less the larger of work_order_qty and delivered_qty. If items are missing, check the plan's filters, that the item has an active BOM, and the counters on the Sales Order Item.

What are planned_qty, production_plan_qty and work_order_qty on a Sales Order Item?

They are counters ERPNext keeps for production. production_plan_qty is what submitted Production Plans have covered, and decides whether the order is listed for a new plan. work_order_qty is what Work Orders have been made for, and with delivered_qty decides the pending quantity. planned_qty and produced_qty record planned and produced quantities for production. None of them falls back when a Work Order produces less than planned.

How do I check material availability for production planning in ERPNext?

In the Production Plan, get the raw materials for the planned items: ERPNext compares the BOM requirement for the planned quantity with stock in the warehouses you choose, and lists shortages to raise Material Requests for. Run it just before you create Work Orders, as stock moves in between.

Why does Get Items not show items without a BOM?

A Production Plan is for manufactured items, which need a Bill of Materials. Get Items only returns items with an active BOM (is_active = 1); that is by design, not a bug. If a manufactured item is missing, check that its BOM is submitted and active.

Can I run production planning for a single Sales Order?

Yes. In the Production Plan, filter on that Sales Order (or its customer or item) when you get the Sales Orders, so only that order's items come in.

How do I handle multi-level BOMs in production planning?

After getting items, click "Get Sub Assembly Items" in the Production Plan. It explodes the BOMs and adds a row for each sub-assembly to make, and Work Orders are created for the sub-assemblies as well as the parent. The Sales Order counters sit on the top-level item.

Which ERPNext version does this guide apply to?

The formulas above are from the ERPNext v15 source (production_plan.py, read on 12 October 2026). Check the same file on your branch if you are on v14 or v16, as the planning code changes between major versions.

Production planning with partial production goes wrong because the Sales Order counters record what was planned or ordered, not what was made. Check the counters against the Work Orders, plan the shortfall deliberately with a note of why, and keep manual edits to ERPNext's counters out of the routine. The calculator and the debugger help you diagnose before you script.

Live demo

Your next step

Production planning not matching your Sales Orders?

Manufacturing

Made to order

3 screens · about 5 min · you end with stock moved

See it live

Sales OrderTo deliver and bill

The customer's confirmed order: who it's for, the items at their price list and when it's due.

Customer
A demo customer
Prices
From their price list

Mith Demo Traders · demo company

Manufacturing & distribution

Now see how ERPNext runs a plant like yours

How we set up ERPNext for manufacturers, from bills of materials and job work to costing and the shop floor.

Comments & ratings

No comments yet. Start a new discussion.

0

Manoj · Published on 4 August 2026

Worked with us? Leave a Google review

Questions about this? Talk to the team.

Book a 30-minute Google Meet, WhatsApp us, or send a message. The engineer who works on this replies.

Send us a message

Your details go to our team's CRM and are used only to reply.