Filters added
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 8386133..a68b3a1 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.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 flt, nowdate
from frappe import _
@@ -183,16 +183,24 @@
return stock_entry.as_dict()
@frappe.whitelist()
-def get_events(start, end):
+def get_events(start, end, filters=None):
from frappe.desk.reportview import build_match_conditions
if not frappe.has_permission("Production Order"):
frappe.msgprint(_("No Permission"), raise_exception=1)
+ conditions = build_match_conditions("Production Order")
+ conditions = conditions and (" and " + conditions) or ""
+ if filters:
+ filters = json.loads(filters)
+ for key in filters:
+ if filters[key]:
+ conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
+
data = frappe.db.sql("""select name,production_item, start_date,end_date from `tabProduction Order`
where ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
and (start_date between %(start)s and %(end)s) \
or ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
- and end_date between %(start)s and %(end)s))""", {
+ and end_date between %(start)s and %(end)s)){conditions}""".format(conditions=conditions), {
"start": start,
"end": end
}, as_dict=True, update={"allDay": 0})
diff --git a/erpnext/manufacturing/doctype/production_order/production_order_calendar.js b/erpnext/manufacturing/doctype/production_order/production_order_calendar.js
index 68bbc28..d4011a3 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order_calendar.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order_calendar.js
@@ -10,5 +10,25 @@
"allDay": "allDay"
},
gantt: true,
+ filters: [
+ {
+ "fieldtype": "Link",
+ "fieldname": "sales_order",
+ "options": "Sales Order",
+ "label": __("Sales Order")
+ },
+ {
+ "fieldtype": "Link",
+ "fieldname": "production_item",
+ "options": "Item",
+ "label": __("Production Item")
+ },
+ {
+ "fieldtype": "Link",
+ "fieldname": "wip_warehouse",
+ "options": "Warehouse",
+ "label": __("WIP Warehouse")
+ }
+ ],
get_events_method: "erpnext.manufacturing.doctype.production_order.production_order.get_events"
}
\ No newline at end of file