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", "full_name",
"welcome_email_sent", "welcome_email_sent",
"view_attachments", "view_attachments",
"hide_timesheets",
"section_break_5", "section_break_5",
"project_status" "project_status"
], ],
@@ -64,6 +65,13 @@
"in_list_view": 1, "in_list_view": 1,
"label": "View attachments" "label": "View attachments"
}, },
{
"columns": 2,
"default": "0",
"fieldname": "hide_timesheets",
"fieldtype": "Check",
"label": "Hide timesheets"
},
{ {
"fieldname": "section_break_5", "fieldname": "section_break_5",
"fieldtype": "Section Break" "fieldtype": "Section Break"

View File

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

View File

@@ -9,7 +9,7 @@ def get_context(context):
project_user = frappe.db.get_value( project_user = frappe.db.get_value(
"Project User", "Project User",
{"parent": frappe.form_dict.project, "user": frappe.session.user}, {"parent": frappe.form_dict.project, "user": frappe.session.user},
["user", "view_attachments"], ["user", "view_attachments", "hide_timesheets"],
as_dict=True, as_dict=True,
) )
if frappe.session.user != "Administrator" and (not project_user or frappe.session.user == "Guest"): 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.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: if project_user and project_user.view_attachments:
project.attachments = get_attachments(project.name) project.attachments = get_attachments(project.name)