Report calling another Report

Hi Guys,

Is it possible to use a report as a data-set for another report?
The scenario is like this: 3 tables with a simple query report for each and the 4th report (script report) which can call the other 3 reports (passing some filters) to retrieve data.


You can build your script report any way you want, which also includes querying any other table. What are you trying to do?

I have 3 different tables which have 2 similar columns (company and project). I want to build a script to query each table using the 2 fields as filters, count records based on certain criteria, perform some calculation and show the result in tabular format. I already have simple reports for each table (querying all the records) and iā€™d like to use these as raw data for the final report.

Might be following code will help you. This code calls custom report and make html to send email.

def send_now(self):
	email_list = self.email_id.split(",")
	custom_filter = {'from_date': add_days(today(), -15),'to_date': today()}
	report = frappe.get_doc('Report', "Sales Register Detail") 
	columns, data = report.get_data(limit=100 or 100, user = "", filters = custom_filter, as_dict=True)
	columns.insert(0, frappe._dict(fieldname='idx', label='', width='30px'))
	k = 0
	for k in range(len(data)):
		data[k]['idx'] = k+1
	html = frappe.render_template('frappe/templates/includes/print_table.html', {'columns': columns,'data':data})  

1 Like

@kolate_sambhaji How to do so in script report?

Its python script, similar to get_doc and call functions of doc.
You can get Query Report and Script report using this method.

@kolate_sambhaji Could you give an example of that, please?

Same code is used in frappe to send auto email alert.
You will get report content using below script.