timesheet patch update

This commit is contained in:
Rushabh Mehta 2013-03-04 16:21:54 +05:30
parent 040e599e99
commit 3e712f212a
3 changed files with 35 additions and 12 deletions

View File

@ -2,8 +2,21 @@ import webnotes
def execute():
# convert timesheet details to time logs
webnotes.reload_doc("projects", "doctype", "time_log")
# copy custom fields
custom_map = {"Timesheet":[], "Timesheet Detail":[]}
for custom_field in webnotes.conn.sql("""select * from `tabCustom Field` where
dt in ('Timesheet', 'Timesheet Detail')""", as_dict=True):
custom_map[custom_field.dt].append(custom_field.fieldname)
custom_field.doctype = "Custom Field"
custom_field.dt = "Time Log"
custom_field.insert_after = None
cf = webnotes.bean(custom_field).insert()
for name in webnotes.conn.sql_list("""select name from tabTimesheet"""):
ts = webnotes.bean("Timesheet", name)
for tsd in ts.doclist.get({"doctype":"Timesheet Detail"}):
if not webnotes.conn.exists("Project", tsd.project_name):
tsd.project_name = None
@ -20,8 +33,18 @@ def execute():
"project": tsd.project_name,
"note": ts.doc.notes,
"file_list": ts.doc.file_list,
"_user_tags": ts.doc._user_tags
"_user_tags": ts.doc._user_tags,
"owner": ts.doc.owner,
"creation": ts.doc.creation,
"modified_by": ts.doc.modified_by
})
for key in custom_map["Timesheet"]:
tl.doc.fields[key] = ts.doc.fields.get(key)
for key in custom_map["Timesheet Detail"]:
tl.doc.fields[key] = tsd.fields.get(key)
tl.make_obj()
tl.controller.set_status()
tl.controller.calculate_total_hours()

View File

@ -68,7 +68,7 @@ def get_events(start, end):
}, as_dict=True, update={"allDay": 0})
for d in data:
d.title = d.name + ": " + d.activity_type
d.title = d.name + ": " + (d.activity_type or "[Activity Type not set]")
if d.task:
d.title += " for Task: " + d.task
if d.project:

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-02-26 14:58:28",
"creation": "2013-03-04 02:39:45",
"docstatus": 0,
"modified": "2013-03-01 17:48:09",
"modified": "2013-03-04 02:48:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -31,7 +31,6 @@
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"write": 1
},
{
@ -164,6 +163,12 @@
"permlevel": 0,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "column_break_16",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"doctype": "DocField",
"fieldname": "file_list",
@ -185,18 +190,13 @@
"print_hide": 1
},
{
"cancel": 0,
"create": 1,
"doctype": "DocPerm",
"match": "owner",
"role": "Projects User",
"submit": 1
"role": "Projects User"
},
{
"amend": 1,
"cancel": 1,
"doctype": "DocPerm",
"role": "Projects Manager",
"submit": 0
"role": "Projects Manager"
}
]