validate is stock item in stock entry
diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js
index 724b215..a6d233e 100644
--- a/stock/doctype/stock_entry/stock_entry.js
+++ b/stock/doctype/stock_entry/stock_entry.js
@@ -160,6 +160,7 @@
return 'SELECT tabItem.name, tabItem.description, tabBin.actual_qty '
+ 'FROM tabItem, tabBin '
+ 'WHERE tabItem.name = tabBin.item_code '
+ + 'AND tabItem.is_stock_item = "Yes"'
+ 'AND ifnull(`tabBin`.`actual_qty`,0) > 0 '
+ 'AND tabBin.warehouse="'+ d.s_warehouse +'" '
+ 'AND tabItem.docstatus < 2 '
@@ -171,6 +172,7 @@
return 'SELECT tabItem.name, tabItem.description '
+ 'FROM tabItem '
+ 'WHERE tabItem.docstatus < 2 '
+ + 'AND tabItem.is_stock_item = "Yes"'
+ 'AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") '
+ 'AND tabItem.%(key)s LIKE "%s" '
+ 'ORDER BY tabItem.name ASC '
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index dae2d10..deb1bd3 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -36,7 +36,6 @@
def validate(self):
self.validate_serial_nos()
-
pro_obj = self.doc.production_order and \
get_obj('Production Order', self.doc.production_order) or None
diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 0994e50..fae2fcb 100644
--- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -28,6 +28,14 @@
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
+
+ def validate(self):
+ self.validate_mandatory()
+ self.validate_posting_time()
+ self.validate_item()
+ self.actual_amt_check()
+ self.check_stock_frozen_date()
+ self.scrub_posting_time()
#check for item quantity available in stock
def actual_amt_check(self):
@@ -53,13 +61,19 @@
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
def validate_item(self):
- item_det = sql("select name, has_batch_no, docstatus from tabItem where name = '%s'" % self.doc.item_code)
+ item_det = sql("""select name, has_batch_no, docstatus,
+ ifnull(is_stock_item, 'No') from tabItem where name=%s""",
+ self.doc.item_code)
# check item exists
if item_det:
item_det = item_det and item_det[0]
else:
msgprint("Item: '%s' does not exist in the system. Please check." % self.doc.item_code, raise_exception = 1)
+
+ if item_det[3]!='Yes':
+ webnotes.msgprint("""Item: "%s" is not a Stock Item.""" % self.doc.item_code,
+ raise_exception=1)
# check if item is trashed
if cint(item_det[2])==2:
@@ -96,12 +110,4 @@
self.doc.posting_time = '00:00'
if len(self.doc.posting_time.split(':')) > 2:
self.doc.posting_time = '00:00'
-
-
- def validate(self):
- self.validate_mandatory()
- self.validate_posting_time()
- self.validate_item()
- self.actual_amt_check()
- self.check_stock_frozen_date()
- self.scrub_posting_time()
+
\ No newline at end of file