Merge branch 'develop' into pr-dn-return
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index fe5301d..1d41d0f 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -99,6 +99,7 @@
 					target: me.frm,
 					setters: {
 						supplier: me.frm.doc.supplier || undefined,
+						schedule_date: undefined
 					},
 					get_query_filters: {
 						docstatus: 1,
@@ -107,16 +108,16 @@
 						company: me.frm.doc.company
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 
 			this.frm.add_custom_button(__('Purchase Receipt'), function() {
 				erpnext.utils.map_current_doc({
 					method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
 					source_doctype: "Purchase Receipt",
 					target: me.frm,
-					date_field: "posting_date",
 					setters: {
 						supplier: me.frm.doc.supplier || undefined,
+						posting_date: undefined
 					},
 					get_query_filters: {
 						docstatus: 1,
@@ -125,7 +126,7 @@
 						is_return: 0
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 		}
 		this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 9af584e..502e65e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -199,7 +199,7 @@
 						company: me.frm.doc.company
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 	},
 
 	quotation_btn: function() {
@@ -223,7 +223,7 @@
 						company: me.frm.doc.company
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 	},
 
 	delivery_note_btn: function() {
@@ -251,7 +251,7 @@
 						};
 					}
 				});
-			}, __("Get items from"));
+			}, __("Get Items From"));
 	},
 
 	tc_name: function() {
@@ -812,10 +812,10 @@
 			if (cint(frm.doc.docstatus==0) && cur_frm.page.current_view_name!=="pos" && !frm.doc.is_return) {
 				frm.add_custom_button(__('Healthcare Services'), function() {
 					get_healthcare_services_to_invoice(frm);
-				},"Get items from");
+				},"Get Items From");
 				frm.add_custom_button(__('Prescriptions'), function() {
 					get_drugs_to_invoice(frm);
-				},"Get items from");
+				},"Get Items From");
 			}
 		}
 		else {
@@ -1080,7 +1080,7 @@
 				description:'Quantity will be calculated only for items which has "Nos" as UoM. You may change as required for each invoice item.',
 				get_query: function(doc) {
 					return {
-						filters: { 
+						filters: {
 							patient: dialog.get_value("patient"),
 							company: frm.doc.company,
 							docstatus: 1
diff --git a/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html b/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html
index 1351517..0ca940f8 100644
--- a/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html
+++ b/erpnext/accounts/print_format/journal_auditing_voucher/journal_auditing_voucher.html
@@ -17,7 +17,7 @@
             </div>
             <div class="col-xs-6">
                 <table>
-                    <tr><td><strong>Date: </strong></td><td>{{  frappe.utils.formatdate(doc.creation)  }}</td></tr>
+                    <tr><td><strong>Date: </strong></td><td>{{  frappe.utils.format_date(doc.creation)  }}</td></tr>
                 </table>
             </div>
     </div>
diff --git a/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html b/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html
index f2e65d3..283d505 100644
--- a/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html
+++ b/erpnext/accounts/print_format/payment_receipt_voucher/payment_receipt_voucher.html
@@ -5,7 +5,7 @@
     {{ add_header(0, 1, doc, letter_head, no_letterhead, print_settings) }}
 
     {%- for label, value in (
-        (_("Received On"), frappe.utils.formatdate(doc.voucher_date)),
+        (_("Received On"), frappe.utils.format_date(doc.voucher_date)),
         (_("Received From"), doc.pay_to_recd_from),
         (_("Amount"), "<strong>" + doc.get_formatted("total_amount") + "</strong><br>" + (doc.total_amount_in_words or "") + "<br>"),
         (_("Remarks"), doc.remark)
diff --git a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
index a7c3bce..043ac25 100644
--- a/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
+++ b/erpnext/accounts/print_format/purchase_auditing_voucher/purchase_auditing_voucher.html
@@ -8,7 +8,7 @@
         <div class="col-xs-6">
             <table>
             <tr><td><strong>Supplier Name: </strong></td><td>{{ doc.supplier }}</td></tr>
-            <tr><td><strong>Due Date: </strong></td><td>{{ frappe.utils.formatdate(doc.due_date) }}</td></tr>
+            <tr><td><strong>Due Date: </strong></td><td>{{ frappe.utils.format_date(doc.due_date) }}</td></tr>
             <tr><td><strong>Address: </strong></td><td>{{doc.address_display}}</td></tr>
             <tr><td><strong>Contact: </strong></td><td>{{doc.contact_display}}</td></tr>
             <tr><td><strong>Mobile no: </strong> </td><td>{{doc.contact_mobile}}</td></tr>
@@ -17,7 +17,7 @@
         <div class="col-xs-6">
             <table>
                 <tr><td><strong>Voucher No: </strong></td><td>{{ doc.name }}</td></tr>
-                <tr><td><strong>Date: </strong></td><td>{{ frappe.utils.formatdate(doc.creation) }}</td></tr>
+                <tr><td><strong>Date: </strong></td><td>{{ frappe.utils.format_date(doc.creation) }}</td></tr>
             </table>
         </div>
     </div>
diff --git a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
index ef4ada1..a53b593 100644
--- a/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
+++ b/erpnext/accounts/print_format/sales_auditing_voucher/sales_auditing_voucher.html
@@ -8,7 +8,7 @@
         <div class="col-xs-6">
             <table>
             <tr><td><strong>Customer Name: </strong></td><td>{{ doc.customer }}</td></tr>
-            <tr><td><strong>Due Date: </strong></td><td>{{ frappe.utils.formatdate(doc.due_date) }}</td></tr>
+            <tr><td><strong>Due Date: </strong></td><td>{{ frappe.utils.format_date(doc.due_date) }}</td></tr>
             <tr><td><strong>Address: </strong></td><td>{{doc.address_display}}</td></tr>
             <tr><td><strong>Contact: </strong></td><td>{{doc.contact_display}}</td></tr>
             <tr><td><strong>Mobile no: </strong> </td><td>{{doc.contact_mobile}}</td></tr>
@@ -17,7 +17,7 @@
         <div class="col-xs-6">
             <table>
                 <tr><td><strong>Voucher No: </strong></td><td>{{ doc.name }}</td></tr>
-                <tr><td><strong>Date: </strong></td><td>{{ frappe.utils.formatdate(doc.creation) }}</td></tr>
+                <tr><td><strong>Date: </strong></td><td>{{ frappe.utils.format_date(doc.creation) }}</td></tr>
             </table>
         </div>
     </div>
diff --git a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json
index d422876..d9b7b69 100644
--- a/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json
+++ b/erpnext/assets/doctype/asset_finance_book/asset_finance_book.json
@@ -50,13 +50,11 @@
    "reqd": 1
   },
   {
-   "depends_on": "eval:parent.doctype == 'Asset'",
    "fieldname": "depreciation_start_date",
    "fieldtype": "Date",
    "in_list_view": 1,
    "label": "Depreciation Posting Date",
-   "mandatory_depends_on": "eval:parent.doctype == 'Asset'",
-   "reqd": 1
+   "mandatory_depends_on": "eval:parent.doctype == 'Asset'"
   },
   {
    "default": "0",
@@ -87,7 +85,7 @@
  "index_web_pages_for_search": 1,
  "istable": 1,
  "links": [],
- "modified": "2020-10-30 15:22:29.119868",
+ "modified": "2020-11-05 16:30:09.213479",
  "modified_by": "Administrator",
  "module": "Assets",
  "name": "Asset Finance Book",
diff --git a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py
index 60c528b..a506dee 100644
--- a/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py
+++ b/erpnext/assets/doctype/asset_maintenance/asset_maintenance.py
@@ -108,7 +108,7 @@
 @frappe.whitelist()
 @frappe.validate_and_sanitize_search_inputs
 def get_team_members(doctype, txt, searchfield, start, page_len, filters):
-	return frappe.db.get_values('Maintenance Team Member', { 'parent': filters.get("maintenance_team") })
+	return frappe.db.get_values('Maintenance Team Member', { 'parent': filters.get("maintenance_team") }, "team_member")
 
 @frappe.whitelist()
 def get_maintenance_log(asset_name):
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 9f2b971..2f52a9e 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -299,7 +299,7 @@
 			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)));
+						frappe.throw(__("Item Code, warehouse, quantity are required on row {0}", [i+1]));
 					}
 				})
 				me._make_rm_stock_entry(me.dialog.fields_dict.sub_con_rm_items.grid.get_selected_children())
@@ -366,7 +366,7 @@
 						per_ordered: ["<", 99.99],
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 
 		this.frm.add_custom_button(__('Supplier Quotation'),
 			function() {
@@ -382,7 +382,7 @@
 						status: ["!=", "Stopped"],
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 
 		this.frm.add_custom_button(__('Update rate as per last purchase'),
 			function() {
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
index cf30e30..c427242 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -217,13 +217,15 @@
 						source_doctype: "Material Request",
 						target: me.frm,
 						setters: {
-							company: me.frm.doc.company
+							schedule_date: undefined,
+							status: undefined
 						},
 						get_query_filters: {
 							material_request_type: "Purchase",
 							docstatus: 1,
 							status: ["!=", "Stopped"],
-							per_ordered: ["<", 99.99]
+							per_ordered: ["<", 99.99],
+							company: me.frm.doc.company
 						}
 					})
 				}, __("Get Items From"));
@@ -236,32 +238,40 @@
 						source_doctype: "Opportunity",
 						target: me.frm,
 						setters: {
-							company: me.frm.doc.company
+							party_name: undefined,
+							opportunity_from: undefined,
+							status: undefined
 						},
+						get_query_filters: {
+							status: ["not in", ["Closed", "Lost"]],
+							company: me.frm.doc.company
+						}
 					})
 				}, __("Get Items From"));
 
 			// Get items from open Material Requests based on supplier
 			this.frm.add_custom_button(__('Possible Supplier'), function() {
 				// Create a dialog window for the user to pick their supplier
-				var d = new frappe.ui.Dialog({
+				var dialog = new frappe.ui.Dialog({
 					title: __('Select Possible Supplier'),
 					fields: [
-					{fieldname: 'supplier', fieldtype:'Link', options:'Supplier', label:'Supplier', reqd:1},
-					{fieldname: 'ok_button', fieldtype:'Button', label:'Get Items from Material Requests'},
-					]
-				});
-
-				// On the user clicking the ok button
-				d.fields_dict.ok_button.input.onclick = function() {
-					var btn = d.fields_dict.ok_button.input;
-					var v = d.get_values();
-					if(v) {
-						$(btn).set_working();
+						{
+							fieldname: 'supplier',
+							fieldtype:'Link',
+							options:'Supplier',
+							label:'Supplier',
+							reqd:1,
+							description: __("Get Items from Material Requests against this Supplier")
+						}
+					],
+					primary_action_label: __("Get Items"),
+					primary_action: (args) => {
+						if(!args) return;
+						dialog.hide();
 
 						erpnext.utils.map_current_doc({
 							method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_item_from_material_requests_based_on_supplier",
-							source_name: v.supplier,
+							source_name: args.supplier,
 							target: me.frm,
 							setters: {
 								company: me.frm.doc.company
@@ -273,11 +283,11 @@
 								per_ordered: ["<", 99.99]
 							}
 						});
-						$(btn).done_working();
-						d.hide();
+						dialog.hide();
 					}
-				}
-				d.show();
+				});
+
+				dialog.show();
 			}, __("Get Items From"));
 
 			// Get Suppliers
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index 3376e82..a7cab50 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -37,16 +37,18 @@
 						source_doctype: "Material Request",
 						target: me.frm,
 						setters: {
-							company: me.frm.doc.company
+							schedule_date: undefined,
+							status: undefined
 						},
 						get_query_filters: {
 							material_request_type: "Purchase",
 							docstatus: 1,
 							status: ["!=", "Stopped"],
-							per_ordered: ["<", 99.99]
+							per_ordered: ["<", 99.99],
+							company: me.frm.doc.company
 						}
 					})
-				}, __("Get items from"));
+				}, __("Get Items From"));
 
 			this.frm.add_custom_button(__("Request for Quotation"),
 			function() {
@@ -58,16 +60,16 @@
 					source_doctype: "Request for Quotation",
 					target: me.frm,
 					setters: {
-						company: me.frm.doc.company,
 						transaction_date: null
 					},
 					get_query_filters: {
-						supplier: me.frm.doc.supplier
+						supplier: me.frm.doc.supplier,
+						company: me.frm.doc.company
 					},
 					get_query_method: "erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_rfq_containing_supplier"
 
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 		}
 	},
 
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
index e940b60..ddbcdfd 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
@@ -66,7 +66,7 @@
 							company: me.frm.doc.company
 						}
 					});
-				}, __("Get items from"));
+				}, __("Get Items From"));
 		} else if (this.frm.doc.docstatus === 1) {
 			this.frm.add_custom_button(__('Create Maintenance Visit'), function() {
 				frappe.model.open_mapped_doc({
diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
index 2e2a9ce..4cbb02a 100644
--- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
+++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
@@ -62,7 +62,7 @@
 							company: me.frm.doc.company
 						}
 					})
-				}, __("Get items from"));
+				}, __("Get Items From"));
 			this.frm.add_custom_button(__('Warranty Claim'),
 				function() {
 					erpnext.utils.map_current_doc({
@@ -78,7 +78,7 @@
 							company: me.frm.doc.company
 						}
 					})
-				}, __("Get items from"));
+				}, __("Get Items From"));
 			this.frm.add_custom_button(__('Sales Order'),
 				function() {
 					erpnext.utils.map_current_doc({
@@ -94,7 +94,7 @@
 							order_type: me.frm.doc.order_type,
 						}
 					})
-				}, __("Get items from"));
+				}, __("Get Items From"));
 		}
 	},
 });
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index d50d5df..979ba98 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -632,7 +632,7 @@
 execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart')
 execute:frappe.reload_doc('desk', 'doctype', 'dashboard_chart_field')
 erpnext.patches.v12_0.remove_bank_remittance_custom_fields
-erpnext.patches.v12_0.generate_leave_ledger_entries #27-08-2020
+erpnext.patches.v12_0.generate_leave_ledger_entries #04-11-2020
 execute:frappe.delete_doc_if_exists("Report", "Loan Repayment")
 erpnext.patches.v12_0.move_credit_limit_to_customer_credit_limit
 erpnext.patches.v12_0.add_variant_of_in_item_attribute_table
@@ -733,4 +733,5 @@
 erpnext.patches.v13_0.set_payment_channel_in_payment_gateway_account
 erpnext.patches.v13_0.create_healthcare_custom_fields_in_stock_entry_detail
 erpnext.patches.v13_0.update_reason_for_resignation_in_employee
-erpnext.patches.v13_0.update_returned_qty_in_pr_dn
\ No newline at end of file
+execute:frappe.delete_doc("Report", "Quoted Item Comparison")
+erpnext.patches.v13_0.update_returned_qty_in_pr_dn
diff --git a/erpnext/patches/v12_0/generate_leave_ledger_entries.py b/erpnext/patches/v12_0/generate_leave_ledger_entries.py
index 342c129..7afde37 100644
--- a/erpnext/patches/v12_0/generate_leave_ledger_entries.py
+++ b/erpnext/patches/v12_0/generate_leave_ledger_entries.py
@@ -11,8 +11,6 @@
 	frappe.reload_doc("HR", "doctype", "Leave Ledger Entry")
 	frappe.reload_doc("HR", "doctype", "Leave Encashment")
 	frappe.reload_doc("HR", "doctype", "Leave Type")
-	if frappe.db.a_row_exists("Leave Ledger Entry"):
-		return
 
 	if not frappe.get_meta("Leave Allocation").has_field("unused_leaves"):
 		frappe.reload_doc("HR", "doctype", "Leave Allocation")
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 11f70f7..6e21e8e 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -277,7 +277,7 @@
 		var me = this;
 		this.frm.add_custom_button(__("Product Bundle"), function() {
 			erpnext.buying.get_items_from_product_bundle(me.frm);
-		}, __("Get items from"));
+		}, __("Get Items From"));
 	},
 
 	shipping_address: function(){
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index ea2093e..891bbe5 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -539,7 +539,7 @@
 				fieldtype: "Table",
 				label: "Items",
 				cannot_add_rows: cannot_add_row,
-				in_place_edit: true,
+				in_place_edit: false,
 				reqd: 1,
 				data: this.data,
 				get_data: () => {
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 12f3260..661e107 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -116,7 +116,7 @@
 							company: me.frm.doc.company
 						}
 					})
-				}, __("Get items from"), "btn-default");
+				}, __("Get Items From"), "btn-default");
 		}
 
 		this.toggle_reqd_lead_customer();
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 989bd33..73cc0b8 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -236,7 +236,7 @@
 							status: ["!=", "Lost"]
 						}
 					})
-				}, __("Get items from"));
+				}, __("Get Items From"));
 		}
 
 		this.order_type(doc);
@@ -573,12 +573,6 @@
 					"default": 0
 				},
 				{
-					"fieldtype": "Section Break",
-					"label": "",
-					"fieldname": "sec_break_dialog",
-					"hide_border": 1
-				},
-				{
 					fieldname: 'items_for_po', fieldtype: 'Table', label: 'Select Items',
 					fields: [
 						{
@@ -616,16 +610,13 @@
 							read_only:1,
 							in_list_view:1
 						},
-					],
-					data: me.frm.doc.items.map((item) =>{
-						item.pending_qty = (flt(item.stock_qty) - flt(item.ordered_qty)) / flt(item.conversion_factor);
-						return item;
-					}).filter((item) => {return item.pending_qty > 0;})
+					]
 				}
 			],
 			primary_action_label: 'Create Purchase Order',
 			primary_action (args) {
 				if (!args) return;
+
 				let selected_items = dialog.fields_dict.items_for_po.grid.get_selected_children();
 				if(selected_items.length == 0) {
 					frappe.throw({message: 'Please select Items from the Table', title: __('Items Required'), indicator:'blue'})
@@ -635,8 +626,9 @@
 
 				var method = args.against_default_supplier ? "make_purchase_order_for_default_supplier" : "make_purchase_order"
 				return frappe.call({
-					type: "GET",
 					method: "erpnext.selling.doctype.sales_order.sales_order." + method,
+					freeze: true,
+					freeze_message: __("Creating Purchase Order ..."),
 					args: {
 						"source_name": me.frm.doc.name,
 						"selected_items": selected_items
@@ -660,8 +652,9 @@
 			}
 		});
 
-		dialog.fields_dict["against_default_supplier"].df.onchange = () => {
-			console.log("yo");
+		dialog.fields_dict["against_default_supplier"].df.onchange = () => set_po_items_data(dialog);
+
+		function set_po_items_data (dialog) {
 			var against_default_supplier = dialog.get_value("against_default_supplier");
 			var items_for_po = dialog.get_value("items_for_po");
 
@@ -671,16 +664,28 @@
 				dialog.fields_dict["items_for_po"].df.data = items_with_supplier;
 				dialog.get_field("items_for_po").refresh();
 			} else {
-				let pending_items = me.frm.doc.items.map((item) =>{
-					item.pending_qty = (flt(item.stock_qty) - flt(item.ordered_qty)) / flt(item.conversion_factor);
-					return item;
-					}).filter((item) => {return item.pending_qty > 0;});
+				let po_items = [];
+				me.frm.doc.items.forEach(d => {
+					let pending_qty = (flt(d.stock_qty) - flt(d.ordered_qty)) / flt(d.conversion_factor);
+					if (pending_qty > 0) {
+						po_items.push({
+							"doctype": "Sales Order Item",
+							"name": d.name,
+							"item_name": d.item_name,
+							"item_code": d.item_code,
+							"pending_qty": pending_qty,
+							"uom": d.uom,
+							"supplier": d.supplier
+						});
+					}
+				});
 
-				dialog.fields_dict["items_for_po"].df.data = pending_items;
+				dialog.fields_dict["items_for_po"].df.data = po_items;
 				dialog.get_field("items_for_po").refresh();
 			}
 		}
 
+		set_po_items_data(dialog);
 		dialog.get_field("items_for_po").grid.only_sortable();
 		dialog.get_field("items_for_po").refresh();
 		dialog.wrapper.find('.grid-heading-row .grid-row-check').click();
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index ae227e0..ec1c823 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -779,7 +779,9 @@
 	return data
 
 @frappe.whitelist()
-def make_purchase_order_for_default_supplier(source_name, selected_items=[], target_doc=None):
+def make_purchase_order_for_default_supplier(source_name, selected_items=None, target_doc=None):
+	if not selected_items: return
+
 	if isinstance(selected_items, string_types):
 		selected_items = json.loads(selected_items)
 
@@ -878,7 +880,9 @@
 		frappe.msgprint(_("Purchase Order already created for all Sales Order items"))
 
 @frappe.whitelist()
-def make_purchase_order(source_name, selected_items=[], target_doc=None):
+def make_purchase_order(source_name, selected_items=None, target_doc=None):
+	if not selected_items: return
+
 	if isinstance(selected_items, string_types):
 		selected_items = json.loads(selected_items)
 
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 19d0bec..251a26a 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -151,7 +151,7 @@
 								project: me.frm.doc.project || undefined,
 							}
 						})
-					}, __("Get items from"));
+					}, __("Get Items From"));
 			}
 		}
 
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 8c47098..01edd99 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -90,7 +90,7 @@
 	make_custom_buttons: function(frm) {
 		if (frm.doc.docstatus==0) {
 			frm.add_custom_button(__("Bill of Materials"),
-				() => frm.events.get_items_from_bom(frm), __("Get items from"));
+				() => frm.events.get_items_from_bom(frm), __("Get Items From"));
 		}
 
 		if (frm.doc.docstatus == 1 && frm.doc.status != 'Stopped') {
@@ -147,7 +147,7 @@
 
 		if (frm.doc.docstatus===0) {
 			frm.add_custom_button(__('Sales Order'), () => frm.events.get_items_from_sales_order(frm),
-				__("Get items from"));
+				__("Get Items From"));
 		}
 
 		if (frm.doc.docstatus == 1 && frm.doc.status == 'Stopped') {
@@ -173,7 +173,8 @@
 			source_doctype: "Sales Order",
 			target: frm,
 			setters: {
-				customer: frm.doc.customer || undefined
+				customer: frm.doc.customer || undefined,
+				delivery_date: undefined,
 			},
 			get_query_filters: {
 				docstatus: 1,
@@ -280,8 +281,7 @@
 				fieldname:'default_supplier',
 				fieldtype: 'Link',
 				options: 'Supplier',
-				description: __('Select a Supplier from the Default Suppliers of the items below. \
-					On selection, a Purchase Order will be made against items belonging to the selected Supplier only.'),
+				description: __('Select a Supplier from the Default Suppliers of the items below. On selection, a Purchase Order will be made against items belonging to the selected Supplier only.'),
 				get_query: () => {
 					return{
 						query: "erpnext.stock.doctype.material_request.material_request.get_default_supplier_query",
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index c504e23..bc1d81d 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -128,6 +128,7 @@
 							target: me.frm,
 							setters: {
 								supplier: me.frm.doc.supplier,
+								schedule_date: undefined
 							},
 							get_query_filters: {
 								docstatus: 1,
@@ -136,7 +137,7 @@
 								company: me.frm.doc.company
 							}
 						})
-					}, __("Get items from"));
+					}, __("Get Items From"));
 			}
 
 			if(this.frm.doc.docstatus == 1 && this.frm.doc.status!="Closed") {
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 39fd029..9121758 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -225,7 +225,7 @@
 						docstatus: 1
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 
 			frm.add_custom_button(__('Material Request'), function() {
 				erpnext.utils.map_current_doc({
@@ -240,7 +240,7 @@
 						status: ["not in", ["Transferred", "Issued"]]
 					}
 				})
-			}, __("Get items from"));
+			}, __("Get Items From"));
 		}
 		if (frm.doc.docstatus===0 && frm.doc.purpose == "Material Issue") {
 			frm.add_custom_button(__('Expired Batches'), function() {
@@ -263,7 +263,7 @@
 						}
 					}
 				});
-			}, __("Get items from"));
+			}, __("Get Items From"));
 		}
 
 		frm.events.show_bom_custom_button(frm);
@@ -282,7 +282,7 @@
 	},
 
 	stock_entry_type: function(frm){
-		frm.remove_custom_button('Bill of Materials', "Get items from");
+		frm.remove_custom_button('Bill of Materials', "Get Items From");
 		frm.events.show_bom_custom_button(frm);
 		frm.trigger('add_to_transit');
 	},
@@ -425,9 +425,9 @@
 	show_bom_custom_button: function(frm){
 		if (frm.doc.docstatus === 0 &&
 			['Material Issue', 'Material Receipt', 'Material Transfer', 'Send to Subcontractor'].includes(frm.doc.purpose)) {
-				frm.add_custom_button(__('Bill of Materials'), function() {
-					frm.events.get_items_from_bom(frm);
-				}, __("Get items from"));
+			frm.add_custom_button(__('Bill of Materials'), function() {
+				frm.events.get_items_from_bom(frm);
+			}, __("Get Items From"));
 		}
 	},
 
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 11e758f..f9ac254 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -288,7 +288,6 @@
 		return
 
 	convertible_cols = {}
-
 	is_dict_obj = False
 	if isinstance(result[0], dict):
 		is_dict_obj = True
@@ -310,13 +309,13 @@
 	for row_idx, row in enumerate(result):
 		data = row.items() if is_dict_obj else enumerate(row)
 		for key, value in data:
-			if not key in convertible_columns or not conversion_factors[row_idx]:
+			if key not in convertible_columns or not conversion_factors[row_idx-1]:
 				continue
 
 			if convertible_columns.get(key) == 'rate':
-				new_value = flt(value) * conversion_factors[row_idx]
+				new_value = flt(value) * conversion_factors[row_idx-1]
 			else:
-				new_value = flt(value) / conversion_factors[row_idx]
+				new_value = flt(value) / conversion_factors[row_idx-1]
 
 			if not is_dict_obj:
 				row.insert(key+1, new_value)
diff --git a/erpnext/templates/pages/material_request_info.html b/erpnext/templates/pages/material_request_info.html
index 9d18989..c7a7802 100644
--- a/erpnext/templates/pages/material_request_info.html
+++ b/erpnext/templates/pages/material_request_info.html
@@ -25,7 +25,7 @@
 		</span>
 	</div>
 	<div class="col-xs-6 text-muted text-right small">
-		{{ frappe.utils.formatdate(doc.transaction_date, 'medium') }}
+		{{ frappe.utils.format_date(doc.transaction_date, 'medium') }}
 	</div>
 </div>
 
diff --git a/erpnext/templates/pages/order.html b/erpnext/templates/pages/order.html
index 01b5f6d..af7af11 100644
--- a/erpnext/templates/pages/order.html
+++ b/erpnext/templates/pages/order.html
@@ -42,10 +42,10 @@
 		</span>
 	</div>
 	<div class="col-6 text-muted text-right small">
-		{{ frappe.utils.formatdate(doc.transaction_date, 'medium') }}
+		{{ frappe.utils.format_date(doc.transaction_date, 'medium') }}
 		{% if doc.valid_till %}
 		<p>
-		{{ _("Valid Till") }}: {{ frappe.utils.formatdate(doc.valid_till, 'medium') }}
+		{{ _("Valid Till") }}: {{ frappe.utils.format_date(doc.valid_till, 'medium') }}
 		</p>
 		{% endif %}
 	</div>