Rushabh Mehta | b21eb9a | 2013-02-28 18:42:46 +0530 | [diff] [blame] | 1 | import webnotes |
| 2 | |
| 3 | def execute(): |
| 4 | # convert timesheet details to time logs |
| 5 | for name in webnotes.conn.sql_list("""select name from tabTimesheet"""): |
| 6 | ts = webnotes.bean("Timesheet", name) |
| 7 | for tsd in ts.doclist.get({"doctype":"Timesheet Detail"}): |
Rushabh Mehta | 5423c96 | 2013-03-04 15:45:46 +0530 | [diff] [blame] | 8 | if not webnotes.conn.exists("Project", tsd.project_name): |
| 9 | tsd.project_name = None |
| 10 | if not webnotes.conn.exists("Task", tsd.task_id): |
| 11 | tsd.task_id = None |
| 12 | |
Rushabh Mehta | 040e599 | 2013-03-04 15:47:42 +0530 | [diff] [blame^] | 13 | tl = webnotes.bean({ |
Rushabh Mehta | b21eb9a | 2013-02-28 18:42:46 +0530 | [diff] [blame] | 14 | "doctype": "Time Log", |
| 15 | "status": "Draft", |
| 16 | "from_time": ts.doc.timesheet_date + " " + tsd.act_start_time, |
| 17 | "to_time": ts.doc.timesheet_date + " " + tsd.act_end_time, |
| 18 | "activity_type": tsd.activity_type, |
| 19 | "task": tsd.task_id, |
| 20 | "project": tsd.project_name, |
| 21 | "note": ts.doc.notes, |
| 22 | "file_list": ts.doc.file_list, |
| 23 | "_user_tags": ts.doc._user_tags |
| 24 | }) |
Rushabh Mehta | 040e599 | 2013-03-04 15:47:42 +0530 | [diff] [blame^] | 25 | tl.make_obj() |
| 26 | tl.controller.set_status() |
| 27 | tl.controller.calculate_total_hours() |
| 28 | tl.doc.insert() |