default target warehouse for subcontract
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index a2c670e..61cacce 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -24,6 +24,12 @@
 			};
 		};
 
+		this.frm.fields_dict.bom_no.get_query = function() {
+			return {
+				filters:{ 'docstatus': 1 }
+			};
+		};
+
 		this.frm.fields_dict.mtn_details.grid.get_field('item_code').get_query = function() {
 			if(in_list(["Sales Return", "Purchase Return"], me.frm.doc.purpose) &&
 				me.get_doctype_docname()) {
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index 5f78758..e865e6f 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -238,11 +238,6 @@
    "read_only": 0
   }, 
   {
-   "fieldname": "fold", 
-   "fieldtype": "Fold", 
-   "permlevel": 0
-  }, 
-  {
    "depends_on": "eval:(doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")", 
    "fieldname": "sb1", 
    "fieldtype": "Section Break", 
@@ -340,6 +335,11 @@
    "search_index": 0
   }, 
   {
+   "fieldname": "fold", 
+   "fieldtype": "Fold", 
+   "permlevel": 0
+  }, 
+  {
    "depends_on": "eval:(doc.purpose==\"Sales Return\" || doc.purpose==\"Purchase Return\")", 
    "fieldname": "contact_section", 
    "fieldtype": "Section Break", 
@@ -585,7 +585,7 @@
  "is_submittable": 1, 
  "issingle": 0, 
  "max_attachments": 0, 
- "modified": "2014-09-16 15:56:37.514676", 
+ "modified": "2015-01-29 11:26:46.968041", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Stock Entry", 
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 81a2f59..5a5904a 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -109,8 +109,8 @@
 	def validate_warehouse(self, pro_obj):
 		"""perform various (sometimes conditional) validations on warehouse"""
 
-		source_mandatory = ["Material Issue", "Material Transfer", "Purchase Return"]
-		target_mandatory = ["Material Receipt", "Material Transfer", "Sales Return"]
+		source_mandatory = ["Material Issue", "Material Transfer", "Purchase Return", "Subcontract"]
+		target_mandatory = ["Material Receipt", "Material Transfer", "Sales Return", "Subcontract"]
 
 		validate_for_manufacture_repack = any([d.bom_no for d in self.get("mtn_details")])
 
@@ -467,6 +467,9 @@
 					"Subcontract"]:
 				if self.production_order and self.purpose == "Material Transfer":
 					item_dict = self.get_pending_raw_materials(pro_obj)
+					if self.to_warehouse and pro_obj:
+						for item in item_dict.values():
+							item["to_warehouse"] = pro_obj.wip_warehouse
 				else:
 					if not self.fg_completed_qty:
 						frappe.throw(_("Manufacturing Quantity is mandatory"))
@@ -474,7 +477,8 @@
 					for item in item_dict.values():
 						if pro_obj:
 							item["from_warehouse"] = pro_obj.wip_warehouse
-						item["to_warehouse"] = ""
+
+						item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else ""
 
 				# add raw materials to Stock Entry Detail table
 				self.add_to_stock_entry_detail(item_dict)
@@ -525,7 +529,7 @@
 		item_dict = get_bom_items_as_dict(self.bom_no, qty=qty, fetch_exploded = self.use_multi_level_bom)
 
 		for item in item_dict.values():
-			item.from_warehouse = item.default_warehouse
+			item.from_warehouse = self.from_warehouse or item.default_warehouse
 
 		return item_dict