Merge pull request #46612 from frappe/mergify/bp/version-15-hotfix/pr-46173

feat(projects): add option to hide timesheets for project users (backport #46173)
This commit is contained in:
ruthra kumar
2025-03-19 16:50:42 +05:30
committed by GitHub
3 changed files with 13 additions and 6 deletions

View File

@@ -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"

View File

@@ -56,8 +56,8 @@
{{ empty_state(_("Task")) }}
{% endif %}
<h4 class="my-account-header">{{ _("Timesheets") }}</h4>
{% if doc.timesheets %}
<h4 class="my-account-header">{{ _("Timesheets") }}</h4>
<div class="website-list">
<div class="result">
<div class="web-list-item transaction-list-item">
@@ -73,8 +73,6 @@
{% include "erpnext/templates/includes/projects/project_timesheets.html" %}
</div>
</div>
{% else %}
{{ empty_state(_("Timesheet")) }}
{% endif %}
{% if doc.attachments %}
@@ -136,4 +134,4 @@
</div>
</div>
</div>
{% endmacro %}
{% endmacro %}

View File

@@ -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)