make sensitive fields read only in item master if sle exists
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index 115ced5..3c02629 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -1,6 +1,18 @@
 cur_frm.cscript.refresh = function(doc) {
-  if(cint(doc.is_local) && doc.has_serial_no) set_field_permlevel('has_serial_no', 1);
-  if(cint(doc.is_local) && doc.is_stock_item) set_field_permlevel('is_stock_item', 1);
+	// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
+	// read only if any stock ledger entry exists
+	
+	if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) {
+		var callback = function(r, rt) {
+			if (r.message == 'exists') permlevel = 1;
+			else permlevel = 0;
+				
+			set_field_permlevel('has_serial_no', permlevel);
+			set_field_permlevel('is_stock_item', permlevel);
+			set_field_permlevel('valuation_method', permlevel);
+		}
+		$c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback); 
+	}
 }
 
 
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index a2fbf01..ae67749 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -170,3 +170,11 @@
 			
 		}
 		return str(ret)
+		
+	def check_if_sle_exists(self):
+		"""
+			checks if any stock ledger entry exists for this item
+		"""
+
+		sle = sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
+		return sle and 'exists' or 'not exists'