Merge pull request #3336 from rmehta/ask-password-before-delete

[minor] re-verify password before deleting company transactions
diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js
index 817fdb6..8f28310 100644
--- a/erpnext/setup/doctype/company/company.js
+++ b/erpnext/setup/doctype/company/company.js
@@ -11,31 +11,37 @@
 		erpnext.company.set_chart_of_accounts_options(frm.doc);
 	},
 	delete_company_transactions: function(frm) {
-		var d = frappe.prompt({
-			fieldtype:"Data",
-			fieldname: "company_name",
-			label: __("Please re-type company name to confirm"),
-			reqd: 1,
-			description: __("Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone.")},
-				function(data) {
-					if(data.company_name !== frm.doc.name) {
-						frappe.msgprint("Company name not same");
-						return;
-					}
-					frappe.call({
-						method: "erpnext.setup.doctype.company.delete_company_transactions.delete_company_transactions",
-						args: {
-							company_name: data.company_name
-						},
-						freeze: true,
-						callback: function(r, rt) {
-							if(!r.exc) 
-								frappe.msgprint(__("Successfully deleted all transactions related to this company!"));
+		frappe.verify_password(function() {
+			var d = frappe.prompt({
+				fieldtype:"Data",
+				fieldname: "company_name",
+				label: __("Please re-type company name to confirm"),
+				reqd: 1,
+				description: __("Please make sure you really want to delete all the transactions for this company. Your master data will remain as it is. This action cannot be undone.")},
+					function(data) {
+						if(data.company_name !== frm.doc.name) {
+							frappe.msgprint("Company name not same");
+							return;
 						}
-					});
-				}, __("Delete all the Transactions for this Company"), __("Delete"));
-
-			d.get_primary_btn().addClass("btn-danger");
+						frappe.call({
+							method: "erpnext.setup.doctype.company.delete_company_transactions.delete_company_transactions",
+							args: {
+								company_name: data.company_name
+							},
+							freeze: true,
+							callback: function(r, rt) {
+								if(!r.exc)
+									frappe.msgprint(__("Successfully deleted all transactions related to this company!"));
+							},
+							onerror: function() {
+								frappe.msgprint(__("Wrong Password"));
+							}
+						});
+					}, __("Delete all the Transactions for this Company"), __("Delete")
+				);
+				d.get_primary_btn().addClass("btn-danger");
+			}
+		);
 	}
 });