How to fetch child table from doctype on my web page

Is there anyone here, who can help me?

employee_names = frappe.get_all(“Employee”, distinct=True, pluck=“employee_name”)

status_options = frappe.get_meta(“Asset Request”).get_field(“status”).options.split(“\n”)

workflow_states = frappe.get_all(“Asset Request”, distinct=True, pluck=“workflow_state”)

logged_in_user_id = frappe.session.user

employee = frappe.get_all(“Employee”, filters={“user_id”: logged_in_user_id}, fields=[“name”])

if employee:
employee_name = employee[0].name # Get the name of the employee
asset_requests = frappe.db.sql(“”"
SELECT name, employee, employee_name, status, request_type, transaction_date, workflow_state, reports_to
FROM tabAsset Request
WHERE employee = %s
ORDER BY STR_TO_DATE(transaction_date, ‘%%d-%%m-%%Y %%H:%%i:%%s’) DESC;“”",
(employee_name,),
as_dict=True)
else:
asset_requests = [] # Empty list if the user’s user_id doesn’t match an employee’s user_id

context = {
“employee_names”: employee_names,
“status_options”: status_options,
“workflow_states”: workflow_states,
“asset_requests”: asset_requests
}

employee_names = frappe.get_all(“Employee”, distinct=True, pluck=“employee_name”)

status_options = frappe.get_meta(“Asset Request”).get_field(“status”).options.split(“\n”)

workflow_states = frappe.get_all(“Asset Request”, distinct=True, pluck=“workflow_state”)

logged_in_user_id = frappe.session.user

employee = frappe.get_all(“Employee”, filters={“user_id”: logged_in_user_id}, fields=[“name”])

if employee:
employee_name = employee[0].name # Get the name of the employee
asset_requests = frappe.db.sql(“”"
SELECT name, employee, employee_name, status, request_type, transaction_date, workflow_state, reports_to
FROM tabAsset Request
WHERE employee = %s
ORDER BY STR_TO_DATE(transaction_date, ‘%%d-%%m-%%Y %%H:%%i:%%s’) DESC;“”",
(employee_name,),
as_dict=True)
else:
asset_requests = [] # Empty list if the user’s user_id doesn’t match an employee’s user_id

context = {
“employee_names”: employee_names,
“status_options”: status_options,
“workflow_states”: workflow_states,
“asset_requests”: asset_requests
}

#Using this code, I am able to fetch the field data, but I want to fetch child table also from doctype, how to do it?

Thanks and Regards
Shubham

{% for item in asset_request_items %} {% endfor %}
Item Group Required By Date Required Qty Item Specifications Asset Request Reason Parent Doctype
{{ item.item_group }} {{ item.required_by_date }} {{ item.required_qty }} {{ item.item_specifications }} {{ item.asset_request_reason }} {{ item.parent }}

and

Script

Define asset_request_id based on your logic or fetch it from a source

asset_request_id = “Asset Request Item”

Now you can use asset_request_id in your code to fetch data from the child table

asset_request_items = frappe.get_all(
“Asset Request Item”,
# filters={“parent”: asset_request_id},
fields=[“item_group”, “required_by_date”, “required_qty”, “item_specifications”, “parent”, “asset_request_reason”]
)

context = {
“asset_request_items”: asset_request_items,
# Add other context variables if needed
}

Asset Request is my custom doctype,
“item_group”, “required_by_date”, “required_qty”, “item_specifications”, “parent”, "asset_request_reason
these are fields

output is showing properly

Thanks and Regards
Shubham