From 03d84430b6fdeaa1a5d0252de678f620fb903f1b Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Thu, 30 Jul 2026 08:22:00 +0530 Subject: [PATCH] fix(projects): read the Timesheet label from the employee field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Timesheet was the only doctype where the {...} template on `title` actually rendered: `title_field` was `title`, so `set_title_field()` seeded it from `{employee_name}` on insert. A `default` renders once, so reassigning a draft left the stored title — and every label derived from it — on the previous employee, with no way to correct it from the form because the field is hidden. Point `title_field` at `employee_name` so the label reads the live field instead of a copy that drifts. Existing rows need no backfill. --- erpnext/projects/doctype/timesheet/test_timesheet.py | 11 +++++++++++ erpnext/projects/doctype/timesheet/timesheet.json | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 28ba6cebdef..a21baa74893 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -453,6 +453,17 @@ class TestTimesheet(ERPNextTestSuite): rate = get_timesheet_detail_rate(detail.name, timesheet.currency) self.assertEqual(rate, detail.billing_amount) + def test_title_follows_employee(self): + first = make_employee("_test_timesheet_title_one@example.com", company="_Test Company") + second = make_employee("_test_timesheet_title_two@example.com", company="_Test Company") + + timesheet = make_timesheet(first, simulate=True, do_not_submit=True) + self.assertEqual(timesheet.get_title(), frappe.db.get_value("Employee", first, "employee_name")) + + timesheet.employee = second + timesheet.save() + self.assertEqual(timesheet.get_title(), frappe.db.get_value("Employee", second, "employee_name")) + @staticmethod def _delete_if_exists(doctype, name): if frappe.db.exists(doctype, name): diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json index a703e6cd07f..ea50e074dbe 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.json +++ b/erpnext/projects/doctype/timesheet/timesheet.json @@ -49,7 +49,6 @@ "fields": [ { "allow_on_submit": 1, - "default": "{employee_name}", "fieldname": "title", "fieldtype": "Data", "hidden": 1, @@ -315,7 +314,7 @@ "idx": 1, "is_submittable": 1, "links": [], - "modified": "2026-04-08 12:43:30.658074", + "modified": "2026-07-30 11:04:12.882140", "modified_by": "Administrator", "module": "Projects", "name": "Timesheet", @@ -409,5 +408,5 @@ "sort_field": "creation", "sort_order": "ASC", "states": [], - "title_field": "title" + "title_field": "employee_name" }