From 4a75a424373a643ce7fee77ee0c15153c58accce Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 15 Oct 2014 16:27:51 +0530 Subject: [PATCH] Filters added --- .../production_order/production_order.py | 14 ++++++++++--- .../production_order_calendar.js | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 8386133c20..a68b3a1b10 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 @@ def make_stock_entry(production_order_id, purpose, qty=None): 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 68bbc28a48..d4011a3fb3 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 @@ frappe.views.calendar["Production Order"] = { "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