mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 19:29:10 +00:00
validate is stock item in stock entry
This commit is contained in:
@@ -160,6 +160,7 @@ fld.get_query = function(doc, cdt, cdn) {
|
|||||||
return 'SELECT tabItem.name, tabItem.description, tabBin.actual_qty '
|
return 'SELECT tabItem.name, tabItem.description, tabBin.actual_qty '
|
||||||
+ 'FROM tabItem, tabBin '
|
+ 'FROM tabItem, tabBin '
|
||||||
+ 'WHERE tabItem.name = tabBin.item_code '
|
+ 'WHERE tabItem.name = tabBin.item_code '
|
||||||
|
+ 'AND tabItem.is_stock_item = "Yes"'
|
||||||
+ 'AND ifnull(`tabBin`.`actual_qty`,0) > 0 '
|
+ 'AND ifnull(`tabBin`.`actual_qty`,0) > 0 '
|
||||||
+ 'AND tabBin.warehouse="'+ d.s_warehouse +'" '
|
+ 'AND tabBin.warehouse="'+ d.s_warehouse +'" '
|
||||||
+ 'AND tabItem.docstatus < 2 '
|
+ 'AND tabItem.docstatus < 2 '
|
||||||
@@ -171,6 +172,7 @@ fld.get_query = function(doc, cdt, cdn) {
|
|||||||
return 'SELECT tabItem.name, tabItem.description '
|
return 'SELECT tabItem.name, tabItem.description '
|
||||||
+ 'FROM tabItem '
|
+ 'FROM tabItem '
|
||||||
+ 'WHERE tabItem.docstatus < 2 '
|
+ '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 (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" '
|
+ 'AND tabItem.%(key)s LIKE "%s" '
|
||||||
+ 'ORDER BY tabItem.name ASC '
|
+ 'ORDER BY tabItem.name ASC '
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_serial_nos()
|
self.validate_serial_nos()
|
||||||
|
|
||||||
pro_obj = self.doc.production_order and \
|
pro_obj = self.doc.production_order and \
|
||||||
get_obj('Production Order', self.doc.production_order) or None
|
get_obj('Production Order', self.doc.production_order) or None
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ class DocType:
|
|||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=[]):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
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
|
#check for item quantity available in stock
|
||||||
def actual_amt_check(self):
|
def actual_amt_check(self):
|
||||||
@@ -53,13 +61,19 @@ class DocType:
|
|||||||
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
|
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
|
||||||
|
|
||||||
def validate_item(self):
|
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
|
# check item exists
|
||||||
if item_det:
|
if item_det:
|
||||||
item_det = item_det and item_det[0]
|
item_det = item_det and item_det[0]
|
||||||
else:
|
else:
|
||||||
msgprint("Item: '%s' does not exist in the system. Please check." % self.doc.item_code, raise_exception = 1)
|
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
|
# check if item is trashed
|
||||||
if cint(item_det[2])==2:
|
if cint(item_det[2])==2:
|
||||||
@@ -96,12 +110,4 @@ class DocType:
|
|||||||
self.doc.posting_time = '00:00'
|
self.doc.posting_time = '00:00'
|
||||||
if len(self.doc.posting_time.split(':')) > 2:
|
if len(self.doc.posting_time.split(':')) > 2:
|
||||||
self.doc.posting_time = '00:00'
|
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()
|
|
||||||
Reference in New Issue
Block a user