From adc5bf7b9c76131e0c9f9196b1e939fd56bb78af Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Thu, 16 Sep 2021 16:07:56 +0530 Subject: [PATCH] Merge pull request #27543 from frappe-pr-bot/backport/version-13-hotfix/27538 fix: Validate if item exists on uploading items in stock reco --- .../doctype/stock_reconciliation/stock_reconciliation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index f2c1b9a5153..6676acf87e0 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -592,6 +592,11 @@ def get_stock_balance_for(item_code, warehouse, item_dict = frappe.db.get_value("Item", item_code, ["has_serial_no", "has_batch_no"], as_dict=1) + if not item_dict: + # In cases of data upload to Items table + msg = _("Item {} does not exist.").format(item_code) + frappe.throw(msg, title=_("Missing")) + serial_nos = "" with_serial_no = True if item_dict.get("has_serial_no") else False data = get_stock_balance(item_code, warehouse, posting_date, posting_time,