From 5342ec5055be50e43e657d2b9a5d2860a56f4ce9 Mon Sep 17 00:00:00 2001 From: Ben Cornwell-Mott Date: Tue, 26 Jul 2016 13:47:55 -0700 Subject: [PATCH 1/4] Added employee name to get_employee_list query --- erpnext/projects/doctype/timesheet/timesheet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 895ace379e6..fcea9858b3a 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -293,7 +293,8 @@ def get_activity_cost(employee=None, activity_type=None): @frappe.whitelist() def get_employee_list(doctype, txt, searchfield, start, page_len, filters): - return frappe.db.sql("""select distinct(employee) as employee + test = frappe.db.sql("""select distinct employee, employee_name from `tabSalary Structure` where salary_slip_based_on_timesheet=1 and employee like %(txt)s limit %(start)s, %(page_len)s""", - {'txt': "%%%s%%"%(txt), 'start': start, 'page_len': page_len}) + {'txt': "%%%s%%"% txt, '_txt': txt.replace("%", ""), 'start': start, 'page_len': page_len}) + return test \ No newline at end of file From 19cb34ce40606913151a384cc9f7923de488d6e1 Mon Sep 17 00:00:00 2001 From: Ben Cornwell-Mott Date: Tue, 26 Jul 2016 13:48:36 -0700 Subject: [PATCH 2/4] removed test variable --- erpnext/projects/doctype/timesheet/timesheet.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index fcea9858b3a..4709a0ed2fe 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -293,8 +293,7 @@ def get_activity_cost(employee=None, activity_type=None): @frappe.whitelist() def get_employee_list(doctype, txt, searchfield, start, page_len, filters): - test = frappe.db.sql("""select distinct employee, employee_name + return frappe.db.sql("""select distinct employee, employee_name from `tabSalary Structure` where salary_slip_based_on_timesheet=1 and employee like %(txt)s limit %(start)s, %(page_len)s""", - {'txt': "%%%s%%"% txt, '_txt': txt.replace("%", ""), 'start': start, 'page_len': page_len}) - return test \ No newline at end of file + {'txt': "%%%s%%"% txt, '_txt': txt.replace("%", ""), 'start': start, 'page_len': page_len}) \ No newline at end of file From 5f59a0a00f671236aa081f28d93f51d5fb44a60b Mon Sep 17 00:00:00 2001 From: bcornwellmott Date: Thu, 28 Jul 2016 06:56:20 -0700 Subject: [PATCH 3/4] Corrected SQL query --- erpnext/projects/doctype/timesheet/timesheet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 4709a0ed2fe..b823c8ea14b 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -295,5 +295,5 @@ def get_activity_cost(employee=None, activity_type=None): def get_employee_list(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select distinct employee, employee_name from `tabSalary Structure` where salary_slip_based_on_timesheet=1 - and employee like %(txt)s limit %(start)s, %(page_len)s""", - {'txt': "%%%s%%"% txt, '_txt': txt.replace("%", ""), 'start': start, 'page_len': page_len}) \ No newline at end of file + and employee like %(txt)s or employee_name like %(txt)s) limit %(start)s, %(page_len)s""", + {'txt': "%%%s%%"% txt, 'start': start, 'page_len': page_len}) From e326ae95efb20c8606c19a8ba64efcb7717a7ac6 Mon Sep 17 00:00:00 2001 From: Ben Cornwell-Mott Date: Tue, 26 Jul 2016 19:55:09 -0700 Subject: [PATCH 4/4] Fixed typo --- erpnext/projects/doctype/timesheet/timesheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index b823c8ea14b..a1b757c4bc8 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -295,5 +295,5 @@ def get_activity_cost(employee=None, activity_type=None): def get_employee_list(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select distinct employee, employee_name from `tabSalary Structure` where salary_slip_based_on_timesheet=1 - and employee like %(txt)s or employee_name like %(txt)s) limit %(start)s, %(page_len)s""", + and employee like %(txt)s or employee_name like %(txt)s limit %(start)s, %(page_len)s""", {'txt': "%%%s%%"% txt, 'start': start, 'page_len': page_len})