This could help:
https://frappe.io/docs/user/en/guides/reports-and-printing/how-to-make-script-reports