From 712cd7a426c7b718b37cf4e92e6f4ecd4ddac2a8 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 14 Oct 2014 18:16:53 +0530 Subject: [PATCH] Calender and gantt chart view added for production order doctype --- .../doctype/production_order/production_order.py | 16 ++++++++++++++++ .../production_order_calendar.js | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 erpnext/manufacturing/doctype/production_order/production_order_calendar.js diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index fbca0d59098..8386133c204 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -181,3 +181,19 @@ def make_stock_entry(production_order_id, purpose, qty=None): stock_entry.get_items() return stock_entry.as_dict() + +@frappe.whitelist() +def get_events(start, end): + from frappe.desk.reportview import build_match_conditions + if not frappe.has_permission("Production Order"): + frappe.msgprint(_("No Permission"), raise_exception=1) + + 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))""", { + "start": start, + "end": end + }, as_dict=True, update={"allDay": 0}) + return data diff --git a/erpnext/manufacturing/doctype/production_order/production_order_calendar.js b/erpnext/manufacturing/doctype/production_order/production_order_calendar.js new file mode 100644 index 00000000000..68bbc28a48b --- /dev/null +++ b/erpnext/manufacturing/doctype/production_order/production_order_calendar.js @@ -0,0 +1,14 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.views.calendar["Production Order"] = { + field_map: { + "start": "start_date", + "end": "end_date", + "id": "name", + "title": "production_item", + "allDay": "allDay" + }, + gantt: true, + get_events_method: "erpnext.manufacturing.doctype.production_order.production_order.get_events" +} \ No newline at end of file