From 7f165f19d2e84f750900a8010758958f19ffa1ad Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 1 Sep 2016 00:57:43 +0530 Subject: [PATCH] [Fix] Timesheet employee is missing in patch --- erpnext/patches.txt | 3 +- .../v7_0/convert_timelog_to_timesheet.py | 1 + .../update_missing_employee_in_timesheet.py | 19 ++++++++++++ .../projects/doctype/timesheet/timesheet.json | 29 +++++++++++++++++-- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 erpnext/patches/v7_0/update_missing_employee_in_timesheet.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 76a2409351..1b202d8661 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -311,4 +311,5 @@ erpnext.patches.v7_0.rename_examination_to_assessment 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 \ No newline at end of file +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 diff --git a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py index d00980f6cf..6a6fa26d8e 100644 --- a/erpnext/patches/v7_0/convert_timelog_to_timesheet.py +++ b/erpnext/patches/v7_0/convert_timelog_to_timesheet.py @@ -16,6 +16,7 @@ def execute(): time_sheet = make_timesheet(data.production_order) args = get_timelog_data(data) add_timesheet_detail(time_sheet, args) + time_sheet.employee = data.employee time_sheet.note = data.note time_sheet.company = company diff --git a/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py b/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py new file mode 100644 index 0000000000..c74a40a19b --- /dev/null +++ b/erpnext/patches/v7_0/update_missing_employee_in_timesheet.py @@ -0,0 +1,19 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + timesheet = frappe.db.sql("""select tl.employee as employee, ts.name as name, + tl.modified as modified, tl.modified_by as modified_by, tl.creation as creation, tl.owner as owner + from + `tabTimesheet` ts, `tabTimesheet Detail` tsd, `tabTime Log` tl + where + tsd.parent = ts.name and tl.from_time = tsd.from_time and tl.to_time = tsd.to_time + and tl.hours = tsd.hours and tl.billing_rate = tsd.billing_rate and tsd.idx=1 + and tl.docstatus < 2 and (ts.employee = '' or ts.employee is null)""", as_dict=1) + + for data in timesheet: + ts_doc = frappe.get_doc('Timesheet', data.name) + if len(ts_doc.time_logs) == 1: + frappe.db.sql(""" update `tabTimesheet` set creation = %(creation)s, + owner = %(owner)s, modified = %(modified)s, modified_by = %(modified_by)s, + employee = %(employee)s where name = %(name)s""", data) diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json index 16d71d8c24..3dd5513a88 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.json +++ b/erpnext/projects/doctype/timesheet/timesheet.json @@ -16,6 +16,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "naming_series", "fieldtype": "Select", "hidden": 0, @@ -41,6 +42,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "company", "fieldtype": "Link", "hidden": 0, @@ -67,6 +69,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "depends_on": "", "description": "", "fieldname": "sales_invoice", @@ -94,6 +97,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "column_break_3", "fieldtype": "Column Break", "hidden": 0, @@ -117,6 +121,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "depends_on": "", "fieldname": "salary_slip", "fieldtype": "Link", @@ -144,6 +149,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "default": "Draft", "fieldname": "status", "fieldtype": "Select", @@ -171,7 +177,8 @@ "bold": 0, "collapsible": 0, "collapsible_depends_on": "", - "depends_on": "eval:!doc.production_order", + "columns": 0, + "depends_on": "eval:!doc.production_order || doc.docstatus == 1", "fieldname": "employee_detail", "fieldtype": "Section Break", "hidden": 0, @@ -197,6 +204,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "depends_on": "", "description": "List of employee which has \"Salary Slip Based on Timesheet\" is enabled in salary structure.", "fieldname": "employee", @@ -225,6 +233,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "depends_on": "employee", "fieldname": "employee_name", "fieldtype": "Data", @@ -252,6 +261,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "user", "fieldtype": "Link", "hidden": 0, @@ -278,6 +288,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "column_break_9", "fieldtype": "Column Break", "hidden": 0, @@ -302,6 +313,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "start_date", "fieldtype": "Date", "hidden": 0, @@ -327,6 +339,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "end_date", "fieldtype": "Date", "hidden": 0, @@ -353,6 +366,7 @@ "bold": 0, "collapsible": 0, "collapsible_depends_on": "", + "columns": 0, "depends_on": "production_order", "fieldname": "production_detail", "fieldtype": "Section Break", @@ -379,6 +393,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "production_order", "fieldtype": "Link", "hidden": 0, @@ -405,6 +420,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "section_break_5", "fieldtype": "Section Break", "hidden": 0, @@ -428,6 +444,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "time_logs", "fieldtype": "Table", "hidden": 0, @@ -453,6 +470,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "section_break_8", "fieldtype": "Section Break", "hidden": 0, @@ -477,6 +495,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "default": "0", "description": "", "fieldname": "total_hours", @@ -503,6 +522,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "column_break_10", "fieldtype": "Column Break", "hidden": 0, @@ -527,6 +547,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "default": "0", "depends_on": "", "description": "", @@ -555,6 +576,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "total_costing_amount", "fieldtype": "Float", "hidden": 0, @@ -580,6 +602,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "section_break_18", "fieldtype": "Section Break", "hidden": 0, @@ -604,6 +627,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "note", "fieldtype": "Text Editor", "hidden": 0, @@ -629,6 +653,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "columns": 0, "fieldname": "amended_from", "fieldtype": "Link", "hidden": 0, @@ -662,7 +687,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-08-01 08:54:31.840829", + "modified": "2016-09-01 11:33:38.110421", "modified_by": "Administrator", "module": "Projects", "name": "Timesheet",