From be3ce163526097e67b36edf63696de7981b02ce6 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 20 Jun 2018 17:46:03 +0530 Subject: [PATCH] Daily work summary reply report (#14583) * Add daily work summary reply report * Show user name instead of email * Remove print statement * Change field datatype * ReRun Travis --- .../daily_work_summary_replies/__init__.py | 0 .../daily_work_summary_replies.js | 21 ++++++++ .../daily_work_summary_replies.json | 25 ++++++++++ .../daily_work_summary_replies.py | 49 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 erpnext/hr/report/daily_work_summary_replies/__init__.py create mode 100644 erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.js create mode 100644 erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.json create mode 100644 erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.py diff --git a/erpnext/hr/report/daily_work_summary_replies/__init__.py b/erpnext/hr/report/daily_work_summary_replies/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.js b/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.js new file mode 100644 index 0000000000..0980c6957b --- /dev/null +++ b/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.js @@ -0,0 +1,21 @@ +// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +/* eslint-disable */ +frappe.query_reports["Daily Work Summary Replies"] = { + "filters": [ + { + "fieldname":"group", + "label": __("Group"), + "fieldtype": "Link", + "options": "Daily Work Summary Group", + "reqd": 1 + }, + { + "fieldname": "range", + "label": __("Date Range"), + "fieldtype": "DateRange", + "reqd": 1 + } + ] +} diff --git a/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.json b/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.json new file mode 100644 index 0000000000..04c88506d7 --- /dev/null +++ b/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.json @@ -0,0 +1,25 @@ +{ + "add_total_row": 0, + "creation": "2018-06-04 10:30:25.673452", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "idx": 0, + "is_standard": "Yes", + "modified": "2018-06-04 10:44:04.694509", + "modified_by": "Administrator", + "module": "HR", + "name": "Daily Work Summary Replies", + "owner": "Administrator", + "ref_doctype": "Daily Work Summary", + "report_name": "Daily Work Summary Replies", + "report_type": "Script Report", + "roles": [ + { + "role": "Employee" + }, + { + "role": "HR User" + } + ] +} \ No newline at end of file diff --git a/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.py b/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.py new file mode 100644 index 0000000000..f5eabf5415 --- /dev/null +++ b/erpnext/hr/report/daily_work_summary_replies/daily_work_summary_replies.py @@ -0,0 +1,49 @@ +# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +from frappe import _ +import frappe +from erpnext.hr.doctype.daily_work_summary.daily_work_summary import get_user_emails_from_group + +def execute(filters=None): + if not filters.group: return [], [] + columns, data = get_columns(), get_data(filters) + return columns, data + +def get_columns(filters=None): + columns = [ + { + "label": _("User"), + "fieldname": "user", + "fieldtype": "Data", + "width": 800 + }, + { + "label": _("Reply Count"), + "fieldname": "count", + "fieldtype": "data", + "width": 150, + "align": 'right', + } + ] + return columns + +def get_data(filters): + daily_summary_emails = frappe.get_all('Daily Work Summary', + fields=["name"], + filters=[["creation","Between", filters.range]]) + daily_summary_emails = [d.get('name') for d in daily_summary_emails] + replies = frappe.get_all('Communication', + fields=['content', 'text_content', 'sender'], + filters=[['reference_doctype','=', 'Daily Work Summary'], + ['reference_name', 'in', daily_summary_emails], + ['communication_type', '=', 'Communication'], + ['sent_or_received', '=', 'Received']], + order_by='creation asc') + data = [] + for user in get_user_emails_from_group(filters.group): + userName = frappe.get_value('User', user, 'full_name') + count = len([d for d in replies if d.sender == user]) + data.append([userName, "{0} / {1}".format(count, len(daily_summary_emails))]) + return data \ No newline at end of file