2013-03-04 15:47:42 +05:30

29 lines
931 B
Python

import webnotes
def execute():
# convert timesheet details to time logs
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
if not webnotes.conn.exists("Task", tsd.task_id):
tsd.task_id = None
tl = webnotes.bean({
"doctype": "Time Log",
"status": "Draft",
"from_time": ts.doc.timesheet_date + " " + tsd.act_start_time,
"to_time": ts.doc.timesheet_date + " " + tsd.act_end_time,
"activity_type": tsd.activity_type,
"task": tsd.task_id,
"project": tsd.project_name,
"note": ts.doc.notes,
"file_list": ts.doc.file_list,
"_user_tags": ts.doc._user_tags
})
tl.make_obj()
tl.controller.set_status()
tl.controller.calculate_total_hours()
tl.doc.insert()