From 1b81badd5803302fe419baf5b25855f87b9c0e5e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 3 Apr 2012 11:27:03 +0530 Subject: [PATCH] validation changes for po item --- erpnext/buying/doctype/purchase_common/purchase_common.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py index ca9181f154..597eec4fde 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.py +++ b/erpnext/buying/doctype/purchase_common/purchase_common.py @@ -227,7 +227,7 @@ class DocType(TransactionBase): if d.fields.has_key(x): d.fields[x] = f_lst[x] - item = sql("select is_stock_item, is_purchase_item from tabItem where name=%s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", d.item_code) + item = sql("select is_stock_item, is_purchase_item, is_sub_contracted_item from tabItem where name=%s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", d.item_code) if not item: msgprint("Item %s does not exist in Item Master." % cstr(d.item_code)) raise Exception @@ -239,9 +239,10 @@ class DocType(TransactionBase): raise Exception # validate purchase item - if not item[0][1]=='Yes': - msgprint("Item %s is not purchase item." % (d.item_code)) + if item[0][1] != 'Yes' and item[0][2] != 'Yes': + msgprint("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code)) raise Exception + if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname: # check warehouse, uom in previous doc and in current doc are same.