How to Override query_report.js to Use a Custom PDF Template?

Hello everyone,

I’m trying to customize the PDF generation for reports in the Frappe framework. Currently, when I print a report, it uses the core template to generate a PDF, which works fine. However, I’d like to use my own custom template instead of the core template.

To achieve this, I want to override the core method in query_report.js that calls the core template. I’d like to redirect it to my custom template and pass my arguments to it.

Questions:

  1. How can I override query_report.js without affecting the core files?
  2. What’s the recommended way to pass custom arguments to my template?

I’d appreciate any guidance or code examples to help me achieve this. Thank you!