Holiday List name changed and workstation filter added to time log

This commit is contained in:
Neil Trini Lasrado
2014-11-25 18:55:42 +05:30
committed by Nabin Hait
parent 812cd8a8ce
commit 5ec7542519
9 changed files with 41 additions and 23 deletions

View File

@@ -4,7 +4,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import frappe, json
from frappe import _
from frappe.utils import cstr, cint, comma_and
@@ -135,23 +135,31 @@ def get_workstation(production_order, operation):
parent=%s and operation = %s""", (idx, production_order, operation), as_dict=1)[0]
@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("Time Log"):
frappe.msgprint(_("No Permission"), raise_exception=1)
match = build_match_conditions("Time Log")
data = frappe.db.sql("""select name, from_time, to_time,
activity_type, task, project from `tabTime Log`
where from_time between '%(start)s' and '%(end)s' or to_time between '%(start)s' and '%(end)s'
%(match)s""" % {
"start": start,
"end": end,
"match": match and (" and " + match) or ""
}, as_dict=True, update={"allDay": 0})
conditions = build_match_conditions("Time Log")
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, from_time, to_time,
activity_type, task, project, production_order, workstation from `tabTime Log`
where ( from_time between %(start)s and %(end)s or to_time between %(start)s and %(end)s )
{conditions}""".format(conditions=conditions), {
"start": start,
"end": end
}, as_dict=True, update={"allDay": 0})
for d in data:
d.title = d.name + ": " + (d.activity_type or "[Activity Type not set]")
d.title = d.name + ": " + (d.activity_type or d.production_order or "")
if d.task:
d.title += " for Task: " + d.task
if d.project:

View File

@@ -9,5 +9,14 @@ frappe.views.calendar["Time Log"] = {
"title": "title",
"allDay": "allDay"
},
gantt: true,
filters: [
{
"fieldtype": "Link",
"fieldname": "workstation",
"options": "Workstation",
"label": __("Workstation")
},
],
get_events_method: "erpnext.projects.doctype.time_log.time_log.get_events"
}