added Time Log

This commit is contained in:
Rushabh Mehta
2013-02-26 16:36:41 +05:30
parent 29786e38df
commit ed19666e1b
32 changed files with 185 additions and 170 deletions

View File

View File

@@ -0,0 +1,45 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.widgets.reportview import build_match_conditions
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
self.validate_overlap()
def validate_overlap(self):
existing = webnotes.conn.sql_list("""select name from `tabTime Log` where owner=%s and
((from_time between %s and %s) or (to_time between %s and %s)) and name!=%s""",
(self.doc.owner, self.doc.from_time, self.doc.to_time, self.doc.from_time,
self.doc.to_time, self.doc.name))
if existing:
webnotes.msgprint(_("This Time Log conflicts with") + ":" + ', '.join(existing),
raise_exception=True)
@webnotes.whitelist()
def get_events(start, end):
match = build_match_conditions("Time Log")
data = webnotes.conn.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})
for d in data:
d.title = d.name + ": " + d.activity_type
if d.task:
d.title += " for Task: " + d.task
if d.project:
d.title += " for Project: " + d.project
return data

View File

@@ -0,0 +1,121 @@
[
{
"creation": "2013-02-26 14:58:28",
"docstatus": 0,
"modified": "2013-02-26 16:09:53",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "TL-.######",
"description": "Log of Activities performed by users against Tasks that can be used for tracking time, billing.",
"doctype": "DocType",
"document_type": "Master",
"module": "Projects",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Time Log",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocPerm",
"name": "__common__",
"parent": "Time Log",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"write": 1
},
{
"doctype": "DocType",
"name": "Time Log"
},
{
"doctype": "DocField",
"fieldname": "from_time",
"fieldtype": "Datetime",
"label": "From Time",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "to_time",
"fieldtype": "Datetime",
"label": "To Time",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "activity_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Activity Type",
"options": "Activity Type",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "task",
"fieldtype": "Link",
"label": "Task",
"options": "Task"
},
{
"doctype": "DocField",
"fieldname": "billable",
"fieldtype": "Check",
"label": "Billable"
},
{
"doctype": "DocField",
"fieldname": "section_break_7",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "note",
"fieldtype": "Text Editor",
"label": "Note"
},
{
"doctype": "DocField",
"fieldname": "section_break_9",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "project",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Project",
"options": "Project"
},
{
"doctype": "DocField",
"fieldname": "sales_invoice",
"fieldtype": "Link",
"label": "Sales Invoice",
"options": "Sales Invoice"
},
{
"create": 1,
"doctype": "DocPerm",
"match": "owner",
"role": "Projects User"
},
{
"doctype": "DocPerm",
"role": "Projects Manager"
}
]

View File

@@ -0,0 +1,10 @@
wn.views.calendar["Time Log"] = wn.views.Calendar.extend({
field_map: {
"start": "from_time",
"end": "to_time",
"id": "name",
"title": "title",
"allDay": "allDay"
},
get_events_method: "projects.doctype.time_log.time_log.get_events"
})

View File

@@ -91,4 +91,5 @@ class DocType:
webnotes.conn.set(self.doc, 'status', 'Submitted')
def on_cancel(self):
webnotes.conn.set(self.doc, 'status', 'Cancelled')
webnotes.conn.set(self.doc, 'status', 'Cancelled')