From d07557eaf6ffc3c5c285b9101346b8be9d4514d0 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 2 Sep 2016 12:24:54 +0530 Subject: [PATCH] [Fix] Updated timesheet status --- erpnext/patches.txt | 3 ++- erpnext/patches/v7_0/convert_timelog_to_timesheet.py | 6 +++--- erpnext/patches/v7_0/update_status_for_timesheet.py | 11 +++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 erpnext/patches/v7_0/update_status_for_timesheet.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 68a717b1f7..6483ecd7f4 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -313,4 +313,5 @@ erpnext.patches.v7_0.set_portal_settings erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice erpnext.patches.v7_0.fix_duplicate_icons erpnext.patches.v7_0.repost_gle_for_pos_sales_return -erpnext.patches.v7_0.update_missing_employee_in_timesheet \ No newline at end of file +erpnext.patches.v7_0.update_missing_employee_in_timesheet +erpnext.patches.v7_0.update_status_for_timesheet \ No newline at end of file diff --git a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py index 6a6fa26d8e..a176a8f349 100644 --- a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py +++ b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py @@ -19,13 +19,14 @@ def execute(): time_sheet.employee = data.employee time_sheet.note = data.note time_sheet.company = company - + time_sheet.set_status() + time_sheet.set_dates() time_sheet.update_cost() time_sheet.calculate_total_amounts() time_sheet.flags.ignore_validate = True time_sheet.save(ignore_permissions=True) - + # To ignore validate_mandatory_fields function if data.docstatus == 1: time_sheet.db_set("docstatus", 1) @@ -33,7 +34,6 @@ def execute(): d.db_set("docstatus", 1) time_sheet.update_production_order(time_sheet.name) time_sheet.update_task_and_project() - def get_timelog_data(data): return { diff --git a/erpnext/patches/v7_0/update_status_for_timesheet.py b/erpnext/patches/v7_0/update_status_for_timesheet.py new file mode 100644 index 0000000000..117c40c59f --- /dev/null +++ b/erpnext/patches/v7_0/update_status_for_timesheet.py @@ -0,0 +1,11 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.db.sql("""update + `tabTimesheet` as ts, + ( + select min(from_time)as from_time, max(to_time) as to_time, parent from `tabTimesheet Detail` group by parent + ) as tsd + set ts.status = 'Submitted', ts.start_date = tsd.from_time, ts.end_date = tsd.to_time + where tsd.parent = ts.name and ts.status = 'Draft' and ts.docstatus =1""") \ No newline at end of file