diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index abf5fef78d..e185254d9e 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 @@ def make_quotation(source_name, target_doc=None): }, 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 6c6c897ddb..55a54633d0 100644 --- a/erpnext/crm/doctype/opportunity/opportunity_list.js +++ b/erpnext/crm/doctype/opportunity/opportunity_list.js @@ -6,5 +6,16 @@ frappe.listview_settings['Opportunity'] = { 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"}); + }); } };