Merge pull request #2312 from neilLasrado/production-calender-sync

Production calender sync
This commit is contained in:
Nabin Hait 2014-10-28 14:46:21 +05:30
commit a42e89d8a8
3 changed files with 272 additions and 200 deletions

View File

@ -128,6 +128,20 @@
"permlevel": 0, "permlevel": 0,
"read_only": 1 "read_only": 1
}, },
{
"fieldname": "start_date",
"fieldtype": "Datetime",
"label": "Start Date",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "end_date",
"fieldtype": "Datetime",
"label": "End Date",
"permlevel": 0,
"precision": ""
},
{ {
"fieldname": "warehouses", "fieldname": "warehouses",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -232,7 +246,7 @@
"idx": 1, "idx": 1,
"in_create": 0, "in_create": 0,
"is_submittable": 1, "is_submittable": 1,
"modified": "2014-09-15 11:45:48.591196", "modified": "2014-10-27 13:42:31.476892",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Production Order", "name": "Production Order",

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe, json
from frappe.utils import flt, nowdate from frappe.utils import flt, nowdate
from frappe import _ from frappe import _
@ -181,3 +181,27 @@ def make_stock_entry(production_order_id, purpose, qty=None):
stock_entry.get_items() stock_entry.get_items()
return stock_entry.as_dict() return stock_entry.as_dict()
@frappe.whitelist()
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)){conditions}""".format(conditions=conditions), {
"start": start,
"end": end
}, as_dict=True, update={"allDay": 0})
return data

View File

@ -0,0 +1,34 @@
// 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,
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"
}