Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index cfcf929..a3481f3 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -155,7 +155,7 @@
 	#do not allow sales item in maintenance quotation and service item in sales quotation
 	#-----------------------------------------------------------------------------------------------
 	def validate_order_type(self):
-		if self.doc.order_type == 'Maintenance':
+		if self.doc.order_type in ['Maintenance', 'Service']:
 			for d in getlist(self.doclist, 'quotation_details'):
 				is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
 				is_service_item = is_service_item and is_service_item[0][0] or 'No'
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index c852230..5670433 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -222,7 +222,7 @@
 
 // ******************** ITEM CODE ******************************** 
 cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
-	if (doc.order_type == 'Maintenance')
+	if (inList(['Maintenance', 'Service'], doc.order_type))
 		return 'SELECT tabItem.name,tabItem.item_name,tabItem.description \
 			FROM tabItem WHERE tabItem.is_service_item="Yes" \
 			AND tabItem.docstatus != 2 \
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 4faa6a3..f4089be 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -54,8 +54,6 @@
 }
 
 
-// Refresh
-//==================
 cur_frm.cscript.refresh = function(doc, cdt, cdn) {
 	cur_frm.clear_custom_buttons();
 	erpnext.hide_naming_series();
@@ -69,17 +67,17 @@
 		if(doc.status != 'Stopped') {
 			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
 			// delivery note
-			if(doc.per_delivered < 100 && doc.order_type!='Maintenance')
+			if(doc.per_delivered < 100 && doc.order_type=='Sales')
 				cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
 			
 			// maintenance
-			if(doc.per_delivered < 100 && doc.order_type=='Maintenance') {
+			if(doc.per_delivered < 100 && (doc.order_type !='Sales')) {
 				cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
 				cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
 			}
 
 			// indent
-			if(doc.order_type != 'Maintenance')
+			if(!doc.order_type || (doc.order_type == 'Sales'))
 				cur_frm.add_custom_button('Make ' + get_doctype_label('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
 			
 			// sales invoice
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index fc7f4bc..d984600 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -242,43 +242,16 @@
 			msgprint("There are no items of the quotation selected.")
 			raise Exception
 
-	# validate sales/ service item against order type
-	#----------------------------------------------------
-	def validate_sales_mntc_item(self):
-		if self.doc.order_type == 'Maintenance':
-			item_field = 'is_service_item'
-			order_type = 'Maintenance Order'
-			item_type = 'service item'
-		else :
-			item_field = 'is_sales_item'
-			order_type = 'Sales Order'
-			item_type = 'sales item'
-		
-		for d in getlist(self.doclist, 'sales_order_details'):
-			res = sql("select %s from `tabItem` where name='%s'"% (item_field,d.item_code))
-			res = res and res[0][0] or 'No'
-			
-			if res == 'No':
-				msgprint("You can not select non "+item_type+" "+d.item_code+" in "+order_type)
-				raise Exception
-	
 	# validate sales/ maintenance quotation against order type
 	#------------------------------------------------------------------
 	def validate_sales_mntc_quotation(self):
 		for d in getlist(self.doclist, 'sales_order_details'):
 			if d.prevdoc_docname:
-				res = sql("select order_type from `tabQuotation` where name=%s", (d.prevdoc_docname))
-				res = res and res[0][0] or ''
-				
-				if self.doc.order_type== 'Maintenance' and res != 'Maintenance':
-					msgprint("You can not select non Maintenance Quotation against Maintenance Order")
-					raise Exception
-				elif self.doc.order_type != 'Maintenance' and res == 'Maintenance':
-					msgprint("You can not select non Sales Quotation against Sales Order")
-					raise Exception
+				res = sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.doc.order_type))
+				if not res:
+					msgprint("""Order Type (%s) should be same in Quotation: %s \
+						and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname))
 
-	#do not allow sales item/quotation in maintenance order and service item/quotation in sales order
-	#-----------------------------------------------------------------------------------------------
 	def validate_order_type(self):
 		#validate delivery date
 		if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
@@ -286,7 +259,6 @@
 			raise Exception
 		
 		self.validate_sales_mntc_quotation()
-		self.validate_sales_mntc_item()
 
 	#check for does customer belong to same project as entered..
 	#-------------------------------------------------------------------------------------------------