[listview] issue: open, close | so, po: stop, unstop
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 9e2d34e..15a6fd1 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+import json
from frappe.utils import cstr, flt
from frappe import msgprint, _, throw
from frappe.model.mapper import get_mapped_doc
@@ -217,6 +218,25 @@
def on_update(self):
pass
+@frappe.whitelist()
+def stop_or_unstop_purchase_orders(names, status):
+ if not frappe.has_permission("Purchase Order", "write"):
+ frappe.throw(_("Not permitted"), frappe.PermissionError)
+
+ names = json.loads(names)
+ for name in names:
+ po = frappe.get_doc("Purchase Order", name)
+ if po.docstatus == 1:
+ if status=="Stopped":
+ if po.status not in ("Stopped", "Cancelled") and (po.per_received < 100 or po.per_billed < 100):
+ po.update_status("Stopped")
+ else:
+ if po.status == "Stopped":
+ po.update_status("Submitted")
+
+ frappe.local.message_log = []
+
+
def set_missing_values(source, target):
target.ignore_pricing_rule = 1
target.run_method("set_missing_values")
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_list.js b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
index 2c28eec..08bf0fe 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order_list.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
@@ -3,7 +3,7 @@
"supplier_name", "per_received", "per_billed", "status"],
get_indicator: function(doc) {
if(doc.status==="Stopped") {
- return [__("Stopped"), "red", "status,=,Stopped"];
+ return [__("Stopped"), "darkgrey", "status,=,Stopped"];
} else if(flt(doc.per_received) < 100 && doc.status!=="Stopped") {
return [__("Not Received"), "orange", "per_received,<,100|status,!=,Stopped"];
} else if(flt(doc.per_received) == 100 && flt(doc.per_billed) < 100 && doc.status!=="Stopped") {
@@ -12,5 +12,17 @@
return [__("Completed"), "green", "per_received,=,100|per_billed,=,100|status,!=,Stopped"];
}
},
- order_by: "per_received asc, modified desc"
+ order_by: "per_received asc, modified desc",
+ onload: function(listview) {
+ var method = "erpnext.buying.doctype.purchase_order.purchase_order.stop_or_unstop_purchase_orders";
+
+ listview.page.add_menu_item(__("Set as Stopped"), function() {
+ listview.call_for_selected_items(method, {"status": "Stopped"});
+ });
+
+ listview.page.add_menu_item(__("Set as Unstopped"), function() {
+ listview.call_for_selected_items(method, {"status": "Submitted"});
+ });
+
+ }
};
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index a06f3d7..890f39a 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+import json
import frappe.utils
from frappe.utils import cstr, flt, getdate, comma_and
from frappe import _
@@ -238,6 +239,24 @@
return list_context
@frappe.whitelist()
+def stop_or_unstop_sales_orders(names, status):
+ if not frappe.has_permission("Sales Order", "write"):
+ frappe.throw(_("Not permitted"), frappe.PermissionError)
+
+ names = json.loads(names)
+ for name in names:
+ so = frappe.get_doc("Sales Order", name)
+ if so.docstatus == 1:
+ if status=="Stop":
+ if so.status not in ("Stopped", "Cancelled") and (so.per_delivered < 100 or so.per_billed < 100):
+ so.stop_sales_order()
+ else:
+ if so.status == "Stopped":
+ so.unstop_sales_order()
+
+ frappe.local.message_log = []
+
+@frappe.whitelist()
def make_material_request(source_name, target_doc=None):
def postprocess(source, doc):
doc.material_request_type = "Purchase"
diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js
index 702c300..085d0e8 100644
--- a/erpnext/selling/doctype/sales_order/sales_order_list.js
+++ b/erpnext/selling/doctype/sales_order/sales_order_list.js
@@ -3,7 +3,7 @@
"status"],
get_indicator: function(doc) {
if(doc.status==="Stopped") {
- return [__("Stopped"), "red", "status,=,Stopped"];
+ return [__("Stopped"), "darkgrey", "status,=,Stopped"];
} else if(flt(doc.per_delivered) < 100 && frappe.datetime.get_diff(doc.delivery_date) < 0) {
return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Stopped"];
} else if(flt(doc.per_delivered) < 100 && doc.status!=="Stopped") {
@@ -14,5 +14,17 @@
return [__("Completed"), "green", "per_delivered,=,100|per_billed,=,100|status,!=,Stopped"];
}
},
- order_by: "per_delivered asc, modified desc"
+ order_by: "per_delivered asc, modified desc",
+ onload: function(listview) {
+ var method = "erpnext.selling.doctype.sales_order.sales_order.stop_or_unstop_sales_orders";
+
+ listview.page.add_menu_item(__("Set as Stopped"), function() {
+ listview.call_for_selected_items(method, {"status": "Stop"});
+ });
+
+ listview.page.add_menu_item(__("Set as Unstopped"), function() {
+ listview.call_for_selected_items(method, {"status": "Unstop"});
+ });
+
+ }
};
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index 841d905..dc6809f 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import frappe
+import json
from frappe import _
from frappe.model.document import Document
@@ -75,3 +76,9 @@
frappe.db.sql("""update `tabIssue` set status = 'Closed'
where status = 'Replied'
and date_sub(curdate(),interval 15 Day) > modified""")
+
+@frappe.whitelist()
+def set_multiple_status(names, status):
+ names = json.loads(names)
+ for name in names:
+ set_status(name, status)
diff --git a/erpnext/support/doctype/issue/issue_list.js b/erpnext/support/doctype/issue/issue_list.js
index 02fd40c..7198b0c 100644
--- a/erpnext/support/doctype/issue/issue_list.js
+++ b/erpnext/support/doctype/issue/issue_list.js
@@ -1,3 +1,14 @@
frappe.listview_settings['Issue'] = {
- colwidths: {"subject": 6}
+ colwidths: {"subject": 6},
+ onload: function(listview) {
+ var method = "erpnext.support.doctype.issue.issue.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"});
+ });
+ }
}