Merge pull request #4420 from rmehta/stock-entry-fix

[minor] allow stock entry for manufacture without production order
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index e9fc134..3965417 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -148,11 +148,11 @@
 					$.each(["from_bom", "bom_no", "fg_completed_qty", "use_multi_level_bom"], function(i, field) {
 						me.frm.set_value(field, r.message[field]);
 					})
-					
+
 					if (me.frm.doc.purpose == "Material Transfer for Manufacture" && !me.frm.doc.to_warehouse)
 						me.frm.set_value("to_warehouse", r.message["wip_warehouse"]);
-					
-					
+
+
 					if (me.frm.doc.purpose == "Manufacture") {
 						if(r.message["additional_costs"].length) {
 							$.each(r.message["additional_costs"], function(i, row) {
@@ -160,7 +160,7 @@
 							})
 							refresh_field("additional_costs");
 						}
-						
+
 						if (!me.frm.doc.from_warehouse) me.frm.set_value("from_warehouse", r.message["wip_warehouse"]);
 						if (!me.frm.doc.to_warehouse) me.frm.set_value("to_warehouse", r.message["fg_warehouse"]);
 					}
@@ -171,7 +171,7 @@
 	},
 
 	toggle_enable_bom: function() {
-		this.frm.toggle_enable("bom_no", !in_list(["Manufacture", "Material Transfer for Manufacture"], this.frm.doc.purpose));
+		this.frm.toggle_enable("bom_no", !!!this.frm.doc.production_order);
 	},
 
 	add_excise_button: function() {
@@ -252,11 +252,11 @@
 	if(doc.purpose == "Material Receipt") {
 		cur_frm.set_value("from_bom", 0);
 	}
-	
+
 	// Addition costs based on purpose
-	cur_frm.toggle_display(["additional_costs", "total_additional_costs", "additional_costs_section"], 
+	cur_frm.toggle_display(["additional_costs", "total_additional_costs", "additional_costs_section"],
 		doc.purpose!='Material Issue');
-	
+
 	cur_frm.fields_dict["items"].grid.set_column_disp("additional_cost", doc.purpose!='Material Issue');
 }
 
@@ -405,4 +405,4 @@
 
 cur_frm.cscript.posting_date = function(doc, cdt, cdn){
 	erpnext.get_fiscal_year(doc.company, doc.posting_date);
-}
\ No newline at end of file
+}
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 79cd8de..9702972 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -170,10 +170,8 @@
 	def validate_production_order(self):
 		if self.purpose in ("Manufacture", "Material Transfer for Manufacture"):
 			# check if production order is entered
-			if not self.production_order:
-				frappe.throw(_("Production order number is mandatory for stock entry purpose manufacture"))
-			# check for double entry
-			if self.purpose=="Manufacture":
+
+			if self.purpose=="Manufacture" and self.production_order:
 				if not self.fg_completed_qty:
 					frappe.throw(_("For Quantity (Manufactured Qty) is mandatory"))
 				self.check_if_operations_completed()