Merge pull request #6424 from rohitwaghchaure/daily_timesheet_summary_permission_issue
[Fix] Daily timesheet summary permission issue
This commit is contained in:
commit
993d7ca630
@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.desk.reportview import build_match_conditions
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters:
|
if not filters:
|
||||||
@ -12,25 +13,36 @@ def execute(filters=None):
|
|||||||
filters["from_time"] = "00:00:00"
|
filters["from_time"] = "00:00:00"
|
||||||
filters["to_time"] = "24:00:00"
|
filters["to_time"] = "24:00:00"
|
||||||
|
|
||||||
columns = [_("Timesheet") + ":Link/Timesheet:120", _("Employee") + "::150", _("Employee Name") + "::150",
|
columns = get_column()
|
||||||
_("From Datetime") + "::140", _("To Datetime") + "::140", _("Hours") + "::70",
|
conditions = get_conditions(filters)
|
||||||
_("Activity Type") + "::120", _("Task") + ":Link/Task:150",
|
|
||||||
_("Project") + ":Link/Project:120", _("Status") + "::70"]
|
|
||||||
|
|
||||||
conditions = "ts.docstatus = 1"
|
|
||||||
if filters.get("from_date"):
|
|
||||||
conditions += " and tsd.from_time >= timestamp(%(from_date)s, %(from_time)s)"
|
|
||||||
if filters.get("to_date"):
|
|
||||||
conditions += " and tsd.to_time <= timestamp(%(to_date)s, %(to_time)s)"
|
|
||||||
|
|
||||||
data = get_data(conditions, filters)
|
data = get_data(conditions, filters)
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
|
def get_column():
|
||||||
|
return [_("Timesheet") + ":Link/Timesheet:120", _("Employee") + "::150", _("Employee Name") + "::150",
|
||||||
|
_("From Datetime") + "::140", _("To Datetime") + "::140", _("Hours") + "::70",
|
||||||
|
_("Activity Type") + "::120", _("Task") + ":Link/Task:150",
|
||||||
|
_("Project") + ":Link/Project:120", _("Status") + "::70"]
|
||||||
|
|
||||||
def get_data(conditions, filters):
|
def get_data(conditions, filters):
|
||||||
time_sheet = frappe.db.sql(""" select ts.name, ts.employee, ts.employee_name,
|
time_sheet = frappe.db.sql(""" select `tabTimesheet`.name, `tabTimesheet`.employee, `tabTimesheet`.employee_name,
|
||||||
tsd.from_time, tsd.to_time, tsd.hours,
|
`tabTimesheet Detail`.from_time, `tabTimesheet Detail`.to_time, `tabTimesheet Detail`.hours,
|
||||||
tsd.activity_type, tsd.task, tsd.project, ts.status from `tabTimesheet Detail` tsd,
|
`tabTimesheet Detail`.activity_type, `tabTimesheet Detail`.task, `tabTimesheet Detail`.project,
|
||||||
`tabTimesheet` ts where ts.name = tsd.parent and %s order by ts.name"""%(conditions), filters, as_list=1)
|
`tabTimesheet`.status from `tabTimesheet Detail`, `tabTimesheet` where
|
||||||
|
`tabTimesheet Detail`.parent = `tabTimesheet`.name and %s order by `tabTimesheet`.name"""%(conditions), filters, as_list=1)
|
||||||
|
|
||||||
return time_sheet
|
return time_sheet
|
||||||
|
|
||||||
|
def get_conditions(filters):
|
||||||
|
conditions = "`tabTimesheet`.docstatus = 1"
|
||||||
|
if filters.get("from_date"):
|
||||||
|
conditions += " and `tabTimesheet Detail`.from_time >= timestamp(%(from_date)s, %(from_time)s)"
|
||||||
|
if filters.get("to_date"):
|
||||||
|
conditions += " and `tabTimesheet Detail`.to_time <= timestamp(%(to_date)s, %(to_time)s)"
|
||||||
|
|
||||||
|
match_conditions = build_match_conditions("Timesheet")
|
||||||
|
if match_conditions:
|
||||||
|
conditions += " and %s" % match_conditions
|
||||||
|
|
||||||
|
return conditions
|
Loading…
Reference in New Issue
Block a user