[enhancement] close opportunities from list view
diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py
index abf5fef..e185254 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.py
+++ b/erpnext/crm/doctype/opportunity/opportunity.py
@@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import frappe
+import frappe, json
from frappe.utils import cstr, cint
from frappe import msgprint, _
from frappe.model.mapper import get_mapped_doc
@@ -200,3 +200,11 @@
}, target_doc, set_missing_values)
return doclist
+
+@frappe.whitelist()
+def set_multiple_status(names, status):
+ names = json.loads(names)
+ for name in names:
+ opp = frappe.get_doc("Opportunity", name)
+ opp.status = status
+ opp.save()
diff --git a/erpnext/crm/doctype/opportunity/opportunity_list.js b/erpnext/crm/doctype/opportunity/opportunity_list.js
index 6c6c897..55a5463 100644
--- a/erpnext/crm/doctype/opportunity/opportunity_list.js
+++ b/erpnext/crm/doctype/opportunity/opportunity_list.js
@@ -6,5 +6,16 @@
indicator[1] = "green";
}
return indicator;
+ },
+ onload: function(listview) {
+ var method = "erpnext.crm.doctype.opportunity.opportunity.set_multiple_status";
+
+ listview.page.add_menu_item(__("Set as Open"), function() {
+ listview.call_for_selected_items(method, {"status": "Open"});
+ });
+
+ listview.page.add_menu_item(__("Set as Closed"), function() {
+ listview.call_for_selected_items(method, {"status": "Closed"});
+ });
}
};