From 5173170be35d4e099827bdbac53242a595fbb1ed Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 23 May 2019 12:10:28 +0530 Subject: [PATCH] fix: validate expense account for opening stock entry --- erpnext/stock/doctype/stock_entry/stock_entry.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 6e0bb2d821..9de639402f 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -238,9 +238,8 @@ class StockEntry(StockController): for d in self.get("items"): if not d.expense_account: frappe.throw(_("Please enter Difference Account")) - elif self.is_opening == "Yes" or not frappe.db.sql("""select name from `tabStock Ledger Entry` limit 1"""): - if frappe.db.get_value("Account", d.expense_account, "report_type") == "Profit and Loss": - frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Entry is an Opening Entry"), OpeningEntryAccountError) + elif self.is_opening == "Yes" and frappe.db.get_value("Account", d.expense_account, "report_type") == "Profit and Loss": + frappe.throw(_("Difference Account must be a Asset/Liability type account, since this Stock Entry is an Opening Entry"), OpeningEntryAccountError) def validate_warehouse(self): """perform various (sometimes conditional) validations on warehouse"""