code alignment
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 501bab0..f49f110 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -140,126 +140,126 @@
 	},
 
 	make_stock_entry: function() {
-				var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; });
-				var me = this;
+		var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; });
+		var me = this;
 
-				if(items.length===1) {
-					me._make_stock_entry(items[0]);
-					return;
-				}
+		if(items.length===1) {
+			me._make_stock_entry(items[0]);
+			return;
+		}
 
-				if(items.length > 1){
-					me.raw_material_data = [];
-					me.show_dialog = 1;
-					let title = "";
-					let fields = [
-					{fieldtype:'Section Break', label: __('Raw Materials')},
-					{fieldname: 'sub_con_rm_items', fieldtype: 'Table',
-						fields: [
-							{
-								fieldtype:'Link',
-								fieldname:'item_code',
-								options: 'Item',
-								label: __('Item'),
-								read_only:1,
-								in_list_view:1
-							},
-							{
-								fieldtype:'Link',
-								fieldname:'rm_item_code',
-								options:'Item',
-								label: __('Raw Material'),
-								read_only:1,
-								in_list_view:1
-							},
-							{
-								fieldtype:'Float',
-								read_only:1,
-								fieldname:'qty',
-								label: __('Quantity'),
-								read_only:1,
-								in_list_view:1
-							},
-							{
-								fieldtype:'Link',
-								read_only:1,
-								fieldname:'warehouse',
-								label: __('Reserve Warehouse'),
-								read_only:1,
-								in_list_view:1
-							},
-							{
-								fieldtype:'Float',
-								read_only:1,
-								fieldname:'rate',
-								label: __('Rate'),
-								hidden:1
-							},
-							{
-								fieldtype:'Float',
-								read_only:1,
-								fieldname:'amount',
-								label: __('Amount'),
-								hidden:1
-							},
-							{
-								fieldtype:'Link',
-								read_only:1,
-								fieldname:'uom',
-								label: __('UOM'),
-								hidden:1
-							}
-						],
-						data: me.raw_material_data,
-						get_data: function() {
-							return me.raw_material_data;
-						}
+		if(items.length > 1){
+			me.raw_material_data = [];
+			me.show_dialog = 1;
+			let title = "";
+			let fields = [
+			{fieldtype:'Section Break', label: __('Raw Materials')},
+			{fieldname: 'sub_con_rm_items', fieldtype: 'Table',
+				fields: [
+					{
+						fieldtype:'Link',
+						fieldname:'item_code',
+						options: 'Item',
+						label: __('Item'),
+						read_only:1,
+						in_list_view:1
+					},
+					{
+						fieldtype:'Link',
+						fieldname:'rm_item_code',
+						options:'Item',
+						label: __('Raw Material'),
+						read_only:1,
+						in_list_view:1
+					},
+					{
+						fieldtype:'Float',
+						read_only:1,
+						fieldname:'qty',
+						label: __('Quantity'),
+						read_only:1,
+						in_list_view:1
+					},
+					{
+						fieldtype:'Link',
+						read_only:1,
+						fieldname:'warehouse',
+						label: __('Reserve Warehouse'),
+						read_only:1,
+						in_list_view:1
+					},
+					{
+						fieldtype:'Float',
+						read_only:1,
+						fieldname:'rate',
+						label: __('Rate'),
+						hidden:1
+					},
+					{
+						fieldtype:'Float',
+						read_only:1,
+						fieldname:'amount',
+						label: __('Amount'),
+						hidden:1
+					},
+					{
+						fieldtype:'Link',
+						read_only:1,
+						fieldname:'uom',
+						label: __('UOM'),
+						hidden:1
 					}
-				]
-
-				me.dialog = new frappe.ui.Dialog({
-					title: title,fields: fields
-					});
-
-				if (me.frm.doc['supplied_items']) {
-					me.frm.doc['supplied_items'].forEach((item, index) => {
-					if (item.rm_item_code && item.main_item_code) {
-							me.raw_material_data.push ({
-								'name':index,
-								'item_code': item.main_item_code,
-								'rm_item_code': item.rm_item_code,
-								'item_name': item.rm_item_code,
-								'qty': item.required_qty,
-								'warehouse':item.reserve_warehouse,
-								'rate':item.rate,
-								'amount':item.amount,
-								'stock_uom':item.stock_uom
-							});
-							me.dialog.fields_dict.sub_con_rm_items.grid.refresh();
-						}
-					})
+				],
+				data: me.raw_material_data,
+				get_data: function() {
+					return me.raw_material_data;
 				}
+			}
+		]
 
-				me.dialog.show()
-				this.dialog.set_primary_action(__('Transfer'), function() {
-					me.values = me.dialog.get_values();
-					if(me.values) {
-						me.values.sub_con_rm_items.map((row,i) => {
-							if (!row.item_code || !row.rm_item_code || !row.warehouse || !row.qty || row.qty === 0) {
-								frappe.throw(__("Item Code, warehouse, quantity are required on row" + (i+1)));
-							}
-						})
-						me._make_rm_stock_entry(me.dialog.fields_dict.sub_con_rm_items.grid.get_selected_children())
-						me.dialog.hide()
-						}
+		me.dialog = new frappe.ui.Dialog({
+			title: title,fields: fields
+			});
+
+		if (me.frm.doc['supplied_items']) {
+			me.frm.doc['supplied_items'].forEach((item, index) => {
+			if (item.rm_item_code && item.main_item_code) {
+					me.raw_material_data.push ({
+						'name':index,
+						'item_code': item.main_item_code,
+						'rm_item_code': item.rm_item_code,
+						'item_name': item.rm_item_code,
+						'qty': item.required_qty,
+						'warehouse':item.reserve_warehouse,
+						'rate':item.rate,
+						'amount':item.amount,
+						'stock_uom':item.stock_uom
 					});
+					me.dialog.fields_dict.sub_con_rm_items.grid.refresh();
 				}
+			})
+		}
 
-				me.dialog.get_close_btn().on('click', () => {
-					me.dialog.hide();
-				});
+		me.dialog.show()
+		this.dialog.set_primary_action(__('Transfer'), function() {
+			me.values = me.dialog.get_values();
+			if(me.values) {
+				me.values.sub_con_rm_items.map((row,i) => {
+					if (!row.item_code || !row.rm_item_code || !row.warehouse || !row.qty || row.qty === 0) {
+						frappe.throw(__("Item Code, warehouse, quantity are required on row" + (i+1)));
+					}
+				})
+				me._make_rm_stock_entry(me.dialog.fields_dict.sub_con_rm_items.grid.get_selected_children())
+				me.dialog.hide()
+				}
+			});
+		}
 
-			},
+		me.dialog.get_close_btn().on('click', () => {
+			me.dialog.hide();
+		});
+
+	},
 
 	_make_stock_entry: function(item) {
 		frappe.call({
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index b8e76b0..372e8d3 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -34,6 +34,12 @@
 			'overflow_type': 'order'
 		}]
 
+	def onload(self):
+		super(PurchaseOrder, self).onload()
+
+		self.set_onload('disable_fetch_last_purchase_rate',
+		cint(frappe.db.get_single_value("Buying Settings", "disable_fetch_last_purchase_rate")))
+
 	def validate(self):
 		super(PurchaseOrder, self).validate()
 
@@ -393,6 +399,7 @@
 @frappe.whitelist()
 def make_stock_entry(purchase_order, item_code):
 	purchase_order = frappe.get_doc("Purchase Order", purchase_order)
+
 	stock_entry = frappe.new_doc("Stock Entry")
 	stock_entry.purpose = "Subcontract"
 	stock_entry.purchase_order = purchase_order.name
@@ -437,6 +444,7 @@
 			stock_entry.supplier_address = purchase_order.supplier_address
 			stock_entry.address_display = purchase_order.address_display
 			stock_entry.company = purchase_order.company
+			stock_entry.docstatus = 0
 			stock_entry.from_bom = 1
 			po_item = [d for d in purchase_order.items if d.item_code == item_code][0]
 			stock_entry.fg_completed_qty = po_item.qty
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index beea97a..742f0fa 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -676,7 +676,7 @@
 		# item dict = { item_code: {qty, description, stock_uom} }
 		item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=qty,
 			fetch_exploded = self.use_multi_level_bom)
-		print item_dict
+
 		for item in item_dict.values():
 			# if source warehouse presents in BOM set from_warehouse as bom source_warehouse
 			item.from_warehouse = self.from_warehouse or item.source_warehouse or item.default_warehouse