Skip to main content

ERPNext how-to & fixes

ERPNext Negative Stock Error: Why It Happens & How to Fix It (2026)

'Stock cannot be negative' or 'N units needed in Warehouse' blocking a submit? Each cause and its fix, and when Allow Negative Stock is the wrong answer.

Updated 29 Oct 202610 min readBy ManojFirst published 27 Jul 2026

ERPNext negative stock errors happen because ERPNext checks the quantity at the exact posting date and time of each entry: if an issue is posted before the receipt that covers it, the item is negative at that instant. The fix is usually to correct the posting sequence or post the missing receipt, not to allow negative stock. You try to submit a Delivery Note, a Sales Invoice, or a POS closing entry, and ERPNext blocks it: "Negative quantity is not allowed", or "N units of Item needed in Warehouse to complete this transaction". The reflex is to tick Allow Negative Stock and move on, which usually trades a visible error for a hidden valuation problem. This guide shows what causes the error, whether allowing negative stock is right for you, and how to fix it by posting sequence or reconciliation. For the other common errors, see our ERPNext troubleshooting guide.

"Stock cannot be negative" is usually not a stock problem. It is a posting-time-order problem. I am Manoj, and I lead ERPNext and Frappe programmes at MithTech, a team of Frappe specialists in Bengaluru. We clear these on client instances regularly, and the fix is rarely "allow negative stock".

What does the error mean?

ERPNext keeps a Stock Ledger Entry for every movement, and it checks the running balance at the exact posting date-time of each entry. When you submit an outward document (a Delivery Note, a Sales Invoice with Update Stock, a manufacturing consumption Stock Entry), it asks: at this posting instant, is there enough on hand? If not, it blocks the submit, because with Allow Negative Stock off (the default), the ledger may not go below zero at any point.

That is why the error can feel illogical: you know the goods arrived, you can see the Purchase Receipt, and the day's totals net out fine. But if the receipt's posting time is after the sale's, then at the sale's instant the warehouse really did show a shortfall.

Which situation are you in?

Pick the cause that matches your case; each maps to its fix and the frappe/erpnext issue that documents the behaviour.

InteractiveNegative Stock Cause Decider

Select what led to the negative-stock error to get its cause, the relevant GitHub issue, and the fix.

Pick why the negative-stock error is firing.

What does the posting-time trap look like?

Say you receive 100 units at 2pm and ship 40 at 9am the same day, keying the receipt first. To ERPNext the timeline is: 9am, ship 40 from a balance of 0 → negative. The receipt at 2pm doesn't retroactively rescue the 9am instant. The fix is to move the receipt's posting time to, say, 8am, before the shipment. Nothing about the quantities changes; only the sequence does.

Backdated entries are the same trap over a longer window: insert or cancel a transaction last month and every balance after it is recalculated, so a point that was fine can now dip below zero.

Should you just enable "Allow Negative Stock"?

Everyone reaches this question. Before you flip the switch in Stock Settings, answer the advisor's three questions for a straight verdict.

InteractiveAllow Negative Stock Advisor

Answer three questions about your setup and get a clear verdict on whether enabling Allow Negative Stock is appropriate.

Reasonable to enable

BOMs that explode only on Sales Order submission legitimately want to issue components before the finished good exists. Allow Negative Stock, scoped to the production warehouse, is the intended fix.

There's a second reason not to turn it on globally: the Stock Settings switch covers every item in the company and overrides the item flags (#38014). If low-value consumables really must go negative, leave the global switch off and tick Allow Negative Stock on those items only, so expensive finished goods stay protected.

How do you fix it properly?

Code recipeFind · Fix · Prevent Recipes

Locate exactly where the balance goes negative, fix it by sequence or reconciliation, and prevent recurrence.

Run this in bench console to find the first date the balance went negative.

bash
# bench --site your-site.local console
import frappe

# 1. Find the exact date the balance first went negative
item = "ITEM-CODE"
warehouse = "Stores - YOUR-CO"

rows = frappe.db.sql(
    """
    SELECT posting_date, posting_time,
           qty_in, qty_out, actual_qty,
           voucher_type, voucher_no
    FROM `tabStock Ledger Entry`
    WHERE item_code = %s AND warehouse = %s
    ORDER BY posting_date, posting_time
    """,
    (item, warehouse),
    as_dict=True,
)

# Walk the running balance and find the first negative
running = 0.0
first_negative = None
for r in rows:
    running += (r.qty_in or 0) - (r.qty_out or 0)
    if running < 0 and first_negative is None:
        first_negative = r
        break

print(first_negative or "no negative in window")
1

Find the negative point

Open Stock > Stock Ledger, filter to the item and warehouse in the error, and read the Balance Qty column top to bottom. The first row that goes below zero is the one to fix; note its posting date and time.

2

Decide: sequence error or real shortage

If an inward entry (Purchase Receipt, Stock Entry) exists but is dated after the outward one, it's a sequence error: go to step 3. If nothing accounts for the missing quantity, it's a real physical shortage: go to step 4.

3

Fix a sequence error

Open the inward document, enable Edit Posting Date and Time, and set its posting date-time to before the failing outward document. Save and submit. The outward document will now validate. If you backdated anything, let the resulting Repost Item Valuation finish before trusting the valuation.

4

Fix a real shortage

Create a Stock Reconciliation (Purpose = Stock Reconciliation) with the actual counted quantity and a valuation rate. ERPNext posts the difference to the Stock Adjustment account. For batch and serial items this is the supported way to clear a negative bundle (PR #45443).

Should you fix the cause, or unblock and reconcile?

Fix the sequence nowUnblock temporarily, reconcile after
An inward entry exists but is mis-datedA shipment must go out this minute and the count is genuinely wrong
Perpetual inventory + valuation mattersLow-value consumables where valuation is noise
The item feeds COGS / margin reportsYou'll run a Stock Reconciliation the same day regardless
You have five minutes to re-date one documentThe blocking document is a POS closing you can't defer (#50787)

At a glance

The receipt exists but is posted after the issuePosting sequenceMove the receipt's posting date and time before the issue
Balance dips after a backdated or cancelled entryRecalculation from the pastLet Repost Item Valuation finish, then fix the sequence
No inward entry covers the quantityReal shortageStock Reconciliation to the counted quantity
Negative on a batch or serial itemBundle-level balanceStock Reconciliation for the batch (PR #45443)
You want negatives for a few cheap itemsPolicyItem-level Allow Negative Stock, global switch off

FAQ

+Why does ERPNext say stock cannot be negative when I clearly received the goods?

Because it checks stock at the exact posting time of each entry, not the day's net. If the outward document's posting time is earlier than the receipt's, the item is negative at that instant. Re-date the receipt to before the issue and the error clears; the quantities don't change, only the sequence does.

+How do I fix a negative stock error in ERPNext without allowing negative stock?

Open the Stock Ledger for the item and warehouse, find the first row where Balance Qty goes below zero, and either correct the posting date-time of the inward entry so it precedes the outward one, or run a Stock Reconciliation with the real counted quantity. Both fix the cause instead of masking it.

+Is it safe to enable Allow Negative Stock in ERPNext?

Only where valuation doesn't matter, or as a temporary unblock you reverse the same day. On a perpetual-inventory setup it corrupts COGS, because a sale from negative stock has no valuation rate to cost against. The Stock Settings switch also covers every item and overrides the item flags, so if you must allow it, tick it on the specific items instead.

+Why can I still submit negative-stock documents with the setting turned off?

First check the item's own Allow Negative Stock flag: ticked on the item, it allows negatives even with the Stock Settings switch off, and with the Stock Settings switch on, every item is allowed whatever its flag says (#38014). There have also been bugs, such as sales invoices submitting with the setting off (#45414, fixed in January 2025). Check both fields and confirm your version has the fixes.

+How do I clear negative stock on a batch or serial item?

A normal posting-time fix often isn't enough because the negative sits at bundle level. Use a Stock Reconciliation to set the correct batch quantity, the path enabled by PR #45443. Confirm your ERPNext version includes that fix before relying on it.

+Does this apply to ERPNext v14, v15 and v16?

Yes. The point-in-time stock validation, the Allow Negative Stock switch, and the posting-time sequencing behave the same across v14, v15 and v16. Only specific batch and serial fixes (like #45443) depend on the version, so check your release. The current releases are v16.53.0 and v15.124.2 (both 28 October 2026, per the frappe/erpnext releases page).

+What happens to my accounts if I leave negative stock on?

Your Stock Balance and your stock account in the General Ledger drift apart, because sales from negative stock post COGS without a real valuation rate. Over a year this shows up as a widening gap between the Stock Balance report and the stock account, the symptom covered in ERPNext perpetual inventory.

What is the bottom line?

The negative-stock error is ERPNext protecting your valuation, not getting in your way. Treat it as a prompt to check the posting sequence, which is usually the real fault, not as a switch to silence. Re-order the receipt and the issue in time, or reconcile to the real count, and the number is right and your books stay clean.

Your next step

Negative stock spreading across warehouses and no one knows why?

See it live

Low stock reorders itself

Stock dips below minimum, suppliers quote in their portal, and the chosen one gets the order.

You end with a purchase order sent · 4 screens · about 6 min

No sign-up, no card, no account.

Next step · ERPNext how-to & fixes

Now see what an audit finds in yours

When the same problems keep coming back, tick what you see and get an audit of the ERPNext you have, then fixes in order of what costs you most.

Comments & ratings

No comments yet. Start a new discussion.

0

Manoj · Published on 27 July 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.