Merge pull request #1649 from anandpdoshi/hotfix

Pass frm to open_mapped_doc
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index d3acb75..ed2a1d4 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -270,7 +270,7 @@
 cur_frm.cscript['Make Delivery Note'] = function() {
 	frappe.model.open_mapped_doc({
 		method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_delivery_note",
-		source_name: cur_frm.doc.name
+		frm: cur_frm
 	})
 }
 
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 57d14b6..8e759f7 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -43,14 +43,14 @@
 	make_purchase_receipt: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 	
 	make_purchase_invoice: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 	
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index d43fab0..37326af 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -39,7 +39,7 @@
 	make_purchase_order: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	}
 });
diff --git a/erpnext/hr/doctype/appraisal/appraisal.js b/erpnext/hr/doctype/appraisal/appraisal.js
index 3cd7adb..84ab964 100644
--- a/erpnext/hr/doctype/appraisal/appraisal.js
+++ b/erpnext/hr/doctype/appraisal/appraisal.js
@@ -5,7 +5,7 @@
 cur_frm.add_fetch('employee', 'employee_name', 'employee_name');
 
 cur_frm.cscript.onload = function(doc,cdt,cdn){
-	if(!doc.status) 
+	if(!doc.status)
 		set_multiple(cdt,cdn,{status:'Draft'});
 	if(doc.amended_from && doc.__islocal) {
 		doc.status = "Draft";
@@ -27,6 +27,7 @@
 	frappe.model.map_current_doc({
 		method: "erpnext.hr.doctype.appraisal.appraisal.fetch_appraisal_template",
 		source_name: cur_frm.doc.kra_template,
+		frm: cur_frm
 	});
 }
 
@@ -71,5 +72,5 @@
 }
 
 cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) {
-	return{	query: "erpnext.controllers.queries.employee_query" }	
-}
\ No newline at end of file
+	return{	query: "erpnext.controllers.queries.employee_query" }
+}
diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js
index 581eacc..fabdfb8 100644
--- a/erpnext/hr/doctype/employee/employee.js
+++ b/erpnext/hr/doctype/employee/employee.js
@@ -58,7 +58,7 @@
 	make_salary_structure: function(btn) {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.hr.doctype.employee.employee.make_salary_structure",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		});
 	}
 });
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js
index e50a99c..8ee67a5 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.js
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.js
@@ -21,7 +21,7 @@
 cur_frm.cscript['Make Salary Slip'] = function() {
 	frappe.model.open_mapped_doc({
 		method: "erpnext.hr.doctype.salary_structure.salary_structure.make_salary_slip",
-		source_name: cur_frm.doc.name
+		frm: cur_frm
 	});
 }
 
diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.js b/erpnext/projects/doctype/time_log_batch/time_log_batch.js
index c2d3535..8fea083 100644
--- a/erpnext/projects/doctype/time_log_batch/time_log_batch.js
+++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.js
@@ -32,7 +32,7 @@
 	make_invoice: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.projects.doctype.time_log_batch.time_log_batch.make_sales_invoice",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		});
 	}
 });
diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js
index 83639d4..66b5270 100644
--- a/erpnext/selling/doctype/lead/lead.js
+++ b/erpnext/selling/doctype/lead/lead.js
@@ -78,14 +78,14 @@
 	create_customer: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.lead.lead.make_customer",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	}, 
 	
 	create_opportunity: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.lead.lead.make_opportunity",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	}
 });
diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js
index 989e4d9..8fd4e82 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.js
+++ b/erpnext/selling/doctype/opportunity/opportunity.js
@@ -73,7 +73,7 @@
 	create_quotation: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.opportunity.opportunity.make_quotation",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	}
 });
@@ -110,7 +110,8 @@
 	cur_frm.toggle_display("contact_info", doc.customer || doc.lead);
 	frappe.model.map_current_doc({
 		method: "erpnext.selling.doctype.lead.lead.make_opportunity",
-		source_name: cur_frm.doc.lead
+		source_name: cur_frm.doc.lead,
+		frm: cur_frm
 	});
 }
 
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index b694529..ee14092 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -134,7 +134,7 @@
 cur_frm.cscript['Make Sales Order'] = function() {
 	frappe.model.open_mapped_doc({
 		method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
-		source_name: cur_frm.doc.name
+		frm: cur_frm
 	})
 }
 
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 75a2c39..dce9916 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -102,35 +102,35 @@
 	make_material_request: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_delivery_note: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_sales_invoice: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_maintenance_schedule: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_schedule",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_maintenance_visit: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 });
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index c265830..c0586b3 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -70,14 +70,14 @@
 	make_sales_invoice: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_installation_note: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		});
 	},
 
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 271fe86..8dabbd3 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -139,21 +139,21 @@
 	make_purchase_order: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_supplier_quotation: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.material_request.material_request.make_supplier_quotation",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
 	make_stock_entry: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	}
 });
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index b23b041..2dc99ef 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -87,7 +87,7 @@
 	make_purchase_invoice: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	},
 
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 245ff74..5373436 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -22,7 +22,6 @@
 				callback: function(r) {
 					if (!r.exc) {
 						me.frm.set_value("expense_account", r.message);
-						me.frm.script_manager.trigger("refresh");
 					}
 				}
 			});
diff --git a/erpnext/support/doctype/customer_issue/customer_issue.js b/erpnext/support/doctype/customer_issue/customer_issue.js
index 74ff7d7..036f14e 100644
--- a/erpnext/support/doctype/customer_issue/customer_issue.js
+++ b/erpnext/support/doctype/customer_issue/customer_issue.js
@@ -20,7 +20,7 @@
 	make_maintenance_visit: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.support.doctype.customer_issue.customer_issue.make_maintenance_visit",
-			source_name: cur_frm.doc.name
+			frm: cur_frm
 		})
 	}
 });
diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js
index 476530b..17cc29d 100644
--- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js
+++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js
@@ -33,7 +33,8 @@
 			this.frm.add_custom_button(__("Make Maintenance Visit"), function() {
 				frappe.model.open_mapped_doc({
 					method: "erpnext.support.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
-					source_name: me.frm.doc.name
+					source_name: me.frm.doc.name,
+					frm: me.frm
 				})
 			});
 		}