From edb2749dfd23fe685ae0a64b65a5e04f11cb74bf Mon Sep 17 00:00:00 2001 From: Vishal Dhayagude Date: Tue, 25 Jul 2017 10:53:12 +0530 Subject: [PATCH] Timesheet web (#10037) * [new]Timesheet added * [new] Customer wise timesheet on webportal added --- erpnext/hooks.py | 11 +++++---- .../projects/doctype/timesheet/timesheet.py | 23 +++++++++++++++++++ .../includes/timesheet/timesheet_row.html | 13 +++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 erpnext/templates/includes/timesheet/timesheet_row.html diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 860aac2ee79..37fd8692e58 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -109,7 +109,8 @@ website_route_rules = [ }, {"from_route": "/jobs", "to_route": "Job Opening"}, {"from_route": "/admissions", "to_route": "Student Admission"}, - {"from_route": "/boms", "to_route": "BOM"} + {"from_route": "/boms", "to_route": "BOM"}, + {"from_route": "/timesheets", "to_route": "Timesheet"}, ] standard_portal_menu_items = [ @@ -122,13 +123,14 @@ standard_portal_menu_items = [ {"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"}, {"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"}, {"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"}, - {"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"} + {"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"}, + {"title": _("Timesheets"), "route": "/timesheets", "reference_doctype": "Timesheet", "role":"Customer"} ] default_roles = [ {'role': 'Customer', 'doctype':'Contact', 'email_field': 'email_id'}, {'role': 'Supplier', 'doctype':'Contact', 'email_field': 'email_id'}, - {'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'} + {'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'}, ] has_website_permission = { @@ -137,7 +139,8 @@ has_website_permission = { "Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission", "Supplier Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission", "Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission", - "Issue": "erpnext.support.doctype.issue.issue.has_website_permission" + "Issue": "erpnext.support.doctype.issue.issue.has_website_permission", + "Timesheet": "erpnext.controllers.website_list_for_contact.has_website_permission" } dump_report_map = "erpnext.startup.report_data_map.data_map" diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 6416176190b..95fd420ba43 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -381,3 +381,26 @@ def get_events(start, end, filters=None): "end": end }, as_dict=True, update={"allDay": 0}) +def get_timesheets_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"): + user = frappe.session.user + # find customer name from contact. + customer = frappe.db.sql('''SELECT dl.link_name FROM `tabContact` AS c inner join \ + `tabDynamic Link` AS dl ON c.first_name=dl.link_name WHERE c.email_id=%s''',user) + # find list of Sales Invoice for made for customer. + sales_invoice = frappe.db.sql('''SELECT name FROM `tabSales Invoice` WHERE customer = %s''',customer) + if customer: + # Return timesheet related data to web portal. + return frappe. db.sql('''SELECT ts.name, tsd.activity_type, ts.status, ts.total_billable_hours, \ + tsd.sales_invoice, tsd.project FROM `tabTimesheet` AS ts inner join `tabTimesheet Detail` \ + AS tsd ON tsd.parent = ts.name where tsd.sales_invoice IN %s order by\ + end_date asc limit {0} , {1}'''.format(limit_start, limit_page_length), [sales_invoice], as_dict = True) + +def get_list_context(context=None): + return { + "show_sidebar": True, + "show_search": True, + 'no_breadcrumbs': True, + "title": _("Timesheets"), + "get_list": get_timesheets_list, + "row_template": "templates/includes/timesheet/timesheet_row.html" + } diff --git a/erpnext/templates/includes/timesheet/timesheet_row.html b/erpnext/templates/includes/timesheet/timesheet_row.html new file mode 100644 index 00000000000..e9cfcda8125 --- /dev/null +++ b/erpnext/templates/includes/timesheet/timesheet_row.html @@ -0,0 +1,13 @@ +
+ +
+
+ {{ doc.name }} +
+
Billable Hours: {{ doc.total_billable_hours}}
+
{{ _(doc.sales_invoice) }}
+
{{ _(doc.project) }}
+
{{ _(doc.activity_type) }}
+
+
+