From 22d7bbb0812a082a785a3e8883f60589b55021f9 Mon Sep 17 00:00:00 2001 From: diptanilsaha Date: Sat, 16 Aug 2025 22:48:45 +0530 Subject: [PATCH] fix: use query builder instead of raw SQL in get_timesheet_detail_rate (cherry picked from commit e563ed0c75fd20135a6ad288e957e75eac7d3b8d) --- erpnext/projects/doctype/timesheet/timesheet.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 7e237209e09..d876570d8f3 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -292,12 +292,16 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to @frappe.whitelist() def get_timesheet_detail_rate(timelog, currency): - timelog_detail = frappe.db.sql( - f"""SELECT tsd.billing_amount as billing_amount, - ts.currency as currency FROM `tabTimesheet Detail` tsd - INNER JOIN `tabTimesheet` ts ON ts.name=tsd.parent - WHERE tsd.name = '{timelog}'""", - as_dict=1, + ts = frappe.qb.DocType("Timesheet") + ts_detail = frappe.qb.DocType("Timesheet Detail") + + timelog_detail = ( + frappe.qb.from_(ts_detail) + .inner_join(ts) + .on(ts.name == ts_detail.parent) + .select(ts_detail.billing_amount.as_("billing_amount"), ts.currency.as_("currency")) + .where(ts_detail.name == timelog) + .run(as_dict=1) )[0] if timelog_detail.currency: