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')

View File

@@ -1,4 +0,0 @@
[
"Projects Home",
"Projects"
]

View File

@@ -1,4 +0,0 @@
{
"Projects": "\u0645\u0634\u0627\u0631\u064a\u0639",
"Projects Home": "\u0635\u0641\u062d\u0629 \u0627\u0644\u0645\u0634\u0631\u0648\u0639\u0627\u062a"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "Proyectos",
"Projects Home": "Home Proyectos"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "Projets",
"Projects Home": "Accueil Projets"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "\u092a\u0930\u093f\u092f\u094b\u091c\u0928\u093e\u0913\u0902",
"Projects Home": "\u092a\u0930\u093f\u092f\u094b\u091c\u0928\u093e\u0913\u0902 \u0918\u0930"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "Projekti",
"Projects Home": "Projekti Po\u010detna"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "Projecten",
"Projects Home": "Projecten Home"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "Projetos",
"Projects Home": "In\u00edcio de Projetos"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "Projetos",
"Projects Home": "Home Projetos"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "\u041f\u0440\u043e\u0458\u0435\u043a\u0442\u0438",
"Projects Home": "\u041f\u0440\u043e\u0458\u0435\u043a\u0442\u0438"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "\u0ba4\u0bbf\u0b9f\u0bcd\u0b9f\u0b99\u0bcd\u0b95\u0bb3\u0bcd",
"Projects Home": "\u0ba4\u0bbf\u0b9f\u0bcd\u0b9f\u0b99\u0bcd\u0b95\u0bb3\u0bcd \u0bae\u0bc1\u0b95\u0baa\u0bcd\u0baa\u0bc1"
}

View File

@@ -1,4 +0,0 @@
{
"Projects": "\u0e42\u0e04\u0e23\u0e07\u0e01\u0e32\u0e23",
"Projects Home": "\u0e2b\u0e19\u0e49\u0e32\u0e41\u0e23\u0e01\u0e42\u0e04\u0e23\u0e07\u0e01\u0e32\u0e23"
}

View File

@@ -21,6 +21,11 @@ wn.module_page["Projects"] = [
description: wn._("Timesheet for tasks."),
doctype:"Timesheet"
},
{
label: wn._("Time Log"),
description: wn._("Time Log for tasks."),
doctype:"Time Log"
},
]
},
{