From 27bab63012fef701a5860d5ad8fc178bf9536fa0 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 --- 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 1ae9606cbf..35217c3f5a 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 67854f484b..0bccb27e62 100644 --- a/erpnext/templates/pages/projects.html +++ b/erpnext/templates/pages/projects.html @@ -57,8 +57,8 @@ {{ empty_state(_("Task")) }} {% endif %} -

{{ _("Timesheets") }}

{% if doc.timesheets %} +

{{ _("Timesheets") }}

@@ -74,8 +74,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 e9296e7cb8..9af273face 100644 --- a/erpnext/templates/pages/projects.py +++ b/erpnext/templates/pages/projects.py @@ -12,7 +12,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, ) @@ -29,7 +29,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) -- GitLab