Unable to Submit, Sales Invoice/ Delivery Note :: Not able to find stock

While creating a Sales Invoice or a Delivery note, it is not able to find the Stock which is present in the Warehouse.

I have checked and double checked the stock balance, invoice dates, added and re-entered the stocks again. But still the issue persists.

Stock is definitely present, but for some reason it is not picked up in the sales cycle.

Following error is seen while creating the delivery note. Also when creating the sales invoice with the same item. This error is coming on multiple items.

This is the Stock Balance report which shows the data is present in the warehouse.

→ There was reported earlier, which i have already seen. (https://discuss.frappe.io/t/problem-on-submit-delivery-note/64771)

Review if there are any open Sales Orders, Delivery Notes, or Stock Reservations for the same items.

Stock > Stock Ledger Report, check the Actual Qty for the item in the specified warehouse. There may be instances where the available stock has been adjusted or consumed by other stock entries not immediately visible in the Stock Balance report.

Confirm that the posting date and time of the Delivery Note are later than or match the posting date of stock entries or receipts for that item. This is essential because stock availability is time-sensitive.

Try running a Stock Reconciliation.

Check the Error Logs.

or try re-indexing the stock levels.

#RespectQuestion #EncourageNewUser

I am having a similar issue, how can I re-index the stock levels?

Can you tell how to do this. I have not found any supporting documentation for this.

Give following a try:

bench --site your-site-name execute erpnext.stock.utils.rebuild_stock_ledger
1 Like

tried running the command as suggested and got the following error:

bench --site your-site-name execute utils.rebuild_stock_ledger
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 269, in execute
    ret = frappe.get_attr(method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1720, in get_attr
    throw(_("App {0} is not installed").format(app_name), AppNotInstalledError)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 606, in throw
    msgprint(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 571, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 522, in _raise_exception
    raise exc
frappe.exceptions.AppNotInstalledError: App utils is not installed

Try following (reposting) (at your own risk, on a non-production system):

bench --site YourSite console

Then. in Python console:

import frappe
from erpnext.stock.doctype.repost_item_valuation.repost_item_valuation import repost

repost_entries = frappe.get_all("Repost Item Valuation", fields=["name"])

for entry in repost_entries:
    doc = frappe.get_doc("Repost Item Valuation", entry.name)
    repost(doc)
    print(f"Reposted: {entry.name}")

print("Stock valuation re-indexing complete.")

Commands executed successfully on my system:

In [13]: for entry in repost_entries:
    ...:     doc = frappe.get_doc("Repost Item Valuation", entry.name)
    ...:     repost(doc)
    ...:     print(f"Reposted: {entry.name}")
    ...:

In [14]: print("Stock valuation re-indexing complete.")
Stock valuation re-indexing complete.

I have not checked if there are any changes, but the code worked in production.

I tried on a test server first, it all looked good :+1:

Thank you!

1 Like