validate is stock item in stock entry

This commit is contained in:
Anand Doshi 2012-12-24 18:38:32 +05:30
parent a0713196d2
commit b9314da054
3 changed files with 18 additions and 11 deletions

View File

@ -160,6 +160,7 @@ fld.get_query = function(doc, cdt, cdn) {
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 @@ fld.get_query = function(doc, cdt, cdn) {
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 '

View File

@ -36,7 +36,6 @@ class DocType(TransactionBase):
def validate(self):
self.validate_serial_nos()
pro_obj = self.doc.production_order and \
get_obj('Production Order', self.doc.production_order) or None

View File

@ -28,6 +28,14 @@ class DocType:
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 @@ class DocType:
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 @@ class DocType:
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()