From 3834d6fbce4a52f356c36a1915566aa7a43d99be Mon Sep 17 00:00:00 2001 From: Marc Ramser Date: Wed, 19 Mar 2025 09:04:15 +0100 Subject: [PATCH] feat(projects): add option to hide timesheets for project users (#46173) * feat: add option to hide timesheets for project users * Added a new "Hide timesheets" checkbox field to Project User doctype that allows to control timesheet visibility for specific users. When enabled, the timesheets section will not be displayed on the project page for that user. * Update projects.html (cherry picked from commit f4aba561ce894bc6d9fded0330b265d07414c330) --- erpnext/projects/doctype/project_user/project_user.json | 8 ++++++++ erpnext/templates/pages/projects.html | 6 ++---- erpnext/templates/pages/projects.py | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/erpnext/projects/doctype/project_user/project_user.json b/erpnext/projects/doctype/project_user/project_user.json index 2f452cc2d75..e82bbfab7bf 100644 --- a/erpnext/projects/doctype/project_user/project_user.json +++ b/erpnext/projects/doctype/project_user/project_user.json @@ -12,6 +12,7 @@ "full_name", "welcome_email_sent", "view_attachments", + "hide_timesheets", "section_break_5", "project_status" ], @@ -64,6 +65,13 @@ "in_list_view": 1, "label": "View attachments" }, + { + "columns": 2, + "default": "0", + "fieldname": "hide_timesheets", + "fieldtype": "Check", + "label": "Hide timesheets" + }, { "fieldname": "section_break_5", "fieldtype": "Section Break" diff --git a/erpnext/templates/pages/projects.html b/erpnext/templates/pages/projects.html index 3b8698f4ab2..d88088c9819 100644 --- a/erpnext/templates/pages/projects.html +++ b/erpnext/templates/pages/projects.html @@ -56,8 +56,8 @@ {{ empty_state(_("Task")) }} {% endif %} -

{{ _("Timesheets") }}

{% if doc.timesheets %} +

{{ _("Timesheets") }}

@@ -73,8 +73,6 @@ {% include "erpnext/templates/includes/projects/project_timesheets.html" %}
- {% else %} - {{ empty_state(_("Timesheet")) }} {% endif %} {% if doc.attachments %} @@ -136,4 +134,4 @@
-{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py index 787c7c0069b..446437bbb32 100644 --- a/erpnext/templates/pages/projects.py +++ b/erpnext/templates/pages/projects.py @@ -9,7 +9,7 @@ def get_context(context): project_user = frappe.db.get_value( "Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user}, - ["user", "view_attachments"], + ["user", "view_attachments", "hide_timesheets"], as_dict=True, ) if frappe.session.user != "Administrator" and (not project_user or frappe.session.user == "Guest"): @@ -25,7 +25,8 @@ def get_context(context): project.name, start=0, item_status="open", search=frappe.form_dict.get("search") ) - project.timesheets = get_timesheets(project.name, start=0, search=frappe.form_dict.get("search")) + if project_user and not project_user.hide_timesheets: + project.timesheets = get_timesheets(project.name, start=0, search=frappe.form_dict.get("search")) if project_user and project_user.view_attachments: project.attachments = get_attachments(project.name)