Hi Community,
i had renamed task doctype to “CSP” and i need script report for that for the following fields label : “QSP ID” from “id” of the transaction
“QSP” from “subject” of the transaction
“Action” from Task Depends On childtable from field “task”
“Action Item” from Task Depends On childtable from field “subject”
“Status” from “status” field of the transaction
“Deadline” from"exp_end_date" field of the transaction
“%Progress” from “progress”
my code is this
def execute(filters=None):
columns = get_columns()
data = get_data(filters)
return columns, data
def get_columns():
return [
{“fieldname”: “id”, “label”: _(“ID”), “fieldtype”: “Data”, “width”: 100}, # ID field
{“fieldname”: “subject”, “label”: _(“Subject”), “fieldtype”: “Data”, “width”: 200}, # Subject field
{“fieldname”: “action”, “label”: _(“Action”), “fieldtype”: “Data”, “width”: 150}, # Task from Task Depends On
{“fieldname”: “action_item”, “label”: _(“Action Item”), “fieldtype”: “Data”, “width”: 200}, # Subject from Task Depends On
{“fieldname”: “status”, “label”: _(“Status”), “fieldtype”: “Data”, “width”: 100},
{“fieldname”: “deadline”, “label”: _(“Deadline”), “fieldtype”: “Date”, “width”: 100}, # Exp End Date field
{“fieldname”: “progress”, “label”: _(“Progress %”), “fieldtype”: “Float”, “width”: 100},
{“fieldname”: “assigned_to”, “label”: _(“Assigned To”), “fieldtype”: “Data”, “width”: 150}
]
def get_data(filters):
data =
# Fetch the CSP records
csp_records = frappe.get_all('CSP', fields=['name', 'subject', 'status', 'exp_end_date', 'progress'], filters=filters)
for csp in csp_records:
csp_id = csp.name # ID field
csp_subject = csp.subject # Subject field
status = csp.status
deadline = csp.exp_end_date # Fetching from exp_end_date field
progress = csp.progress
# Fetch Task Depends On child table data
task_depends_on = frappe.get_all('Task Depends On', filters={'parent': csp_id}, fields=['task', 'subject'])
for task in task_depends_on:
action = task.task
action_item = task.subject
# Fetch Responsible Team child table data
responsible_team = frappe.get_all('Responsible Team', filters={'parent': csp_id}, fields=['employee_name'])
for team_member in responsible_team:
assigned_to = team_member.employee_name
# Append the row to data
data.append({
'id': csp_id, # Using ID field
'subject': csp_subject, # Using Subject field
'action': action,
'action_item': action_item,
'status': status,
'deadline': deadline, # Using exp_end_date as deadline
'progress': progress,
'assigned_to': assigned_to
})
return data
i need like the image
Thanks in Advance