Files added with all functions
diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py
index 4e60477..31f74a6 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.py
+++ b/erpnext/crm/doctype/opportunity/opportunity.py
@@ -84,11 +84,19 @@
 		self.delete_events()
 
 	def has_active_quotation(self):
-		return frappe.db.sql("""
-			select q.name 
-			from `tabQuotation` q, `tabQuotation Item` qi
-			where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s 
-			and q.status not in ('Lost', 'Closed')""", self.name)
+		if not self.with_items:
+			return frappe.get_all('Quotation',
+				{
+					'opportunity': self.name,
+					'status': ("not in", ['Lost', 'Closed']),
+					'docstatus': 1
+				}, 'name')
+		else:
+			return frappe.db.sql("""
+				select q.name
+				from `tabQuotation` q, `tabQuotation Item` qi
+				where q.name = qi.parent and q.docstatus=1 and qi.prevdoc_docname =%s
+				and q.status not in ('Lost', 'Closed')""", self.name)
 
 	def has_ordered_quotation(self):
 		return frappe.db.sql("""
@@ -186,27 +194,6 @@
 	}
 
 @frappe.whitelist()
-def make_request_for_quotation(source_name, target_doc=None):
-	doclist = get_mapped_doc("Opportunity", source_name, {
-		"Opportunity": {
-			"doctype": "Request for Quotation",
-			"validation": {
-				"enquiry_type": ["=", "Sales"]
-			}
-		},
-		"Opportunity Item": {
-			"doctype": "Request for Quotation Item",
-			"field_map": [
-				["name", "opportunity_item"],
-				["parent", "opportunity"],
-				["uom", "uom"]
-			]
-		}
-	}, target_doc)
-
-	return doclist
-
-@frappe.whitelist()
 def make_quotation(source_name, target_doc=None):
 	def set_missing_values(source, target):
 		from erpnext.controllers.accounts_controller import get_default_taxes_and_charges
@@ -233,6 +220,8 @@
 
 		quotation.run_method("set_missing_values")
 		quotation.run_method("calculate_taxes_and_totals")
+		if not source.with_items:
+			quotation.opportunity = source.name
 
 	doclist = get_mapped_doc("Opportunity", source_name, {
 		"Opportunity": {
@@ -256,6 +245,27 @@
 
 	return doclist
 
+ @frappe.whitelist()
+ def make_request_for_quotation(source_name, target_doc=None):
+ 	doclist = get_mapped_doc("Opportunity", source_name, {
+ 		"Opportunity": {
+ 			"doctype": "Request for Quotation",
+ 			"validation": {
+ 				"enquiry_type": ["=", "Sales"]
+ 			}
+ 		},
+ 		"Opportunity Item": {
+ 			"doctype": "Request for Quotation Item",
+ 			"field_map": [
+ 				["name", "opportunity_item"],
+ 				["parent", "opportunity"],
+ 				["uom", "uom"]
+ 			]
+ 		}
+ 	}, target_doc)
+ 
+ 	return doclist
+
 @frappe.whitelist()
 def make_supplier_quotation(source_name, target_doc=None):
 	doclist = get_mapped_doc("Opportunity", source_name, {
@@ -272,7 +282,8 @@
 			}
 		}
 	}, target_doc)
-        return doclist
+
+	return doclist
 
 @frappe.whitelist()
 def set_multiple_status(names, status):