fix(projects): read the Timesheet label from the employee field (backport #57609)

Timesheet title follows the current employee instead of the first one.

(cherry picked from commit 03d84430b6)
(cherry picked from commit 38e5674ea4)
This commit is contained in:
Mihir Kandoi
2026-10-15 14:13:51 +05:30
parent 01e89fd677
commit c3e0a9212d
3 changed files with 14 additions and 5 deletions
@@ -642,6 +642,17 @@ class TestTimesheet(FrappeTestCase):
execute()
self.assertFalse(frappe.db.get_value("Timesheet", timesheet.name, "user"))
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"))
def make_timesheet_without_employee(start, hours):
return frappe.get_doc(
@@ -48,7 +48,6 @@
"fields": [
{
"allow_on_submit": 1,
"default": "{employee_name}",
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
@@ -310,7 +309,7 @@
"idx": 1,
"is_submittable": 1,
"links": [],
"modified": "2026-04-06 22:30:28.513139",
"modified": "2026-07-30 11:04:12.882140",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",
@@ -389,5 +388,5 @@
"sort_field": "modified",
"sort_order": "ASC",
"states": [],
"title_field": "title"
"title_field": "employee_name"
}
@@ -67,7 +67,6 @@
},
{
"allow_on_submit": 1,
"default": "{material_request_type}",
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
@@ -367,7 +366,7 @@
"idx": 70,
"is_submittable": 1,
"links": [],
"modified": "2026-09-22 12:00:00.000000",
"modified": "2026-10-15 12:00:00.000000",
"modified_by": "Administrator",
"module": "Stock",
"name": "Material Request",