Download reports

Another nice functionnality is the reports generation with the report property. The list method allows you to list all reports available on your Odoo server (classified by models), while the download method will retrieve a report as a file (in PDF, HTML... depending of the report).

To list available reports:

>>> odoo.report.list()
{u'ir.module.module': [{u'name': u'Technical guide', u'report_type': u'pdf', u'report_name': u'ir.module.reference'}], u'ir.model': [{u'name': u'Model Overview', u'report_type': u'sxw', u'report_name': u'ir.model.overview'}], u'res.partner': [{u'name': u'Labels', u'report_type': u'pdf', u'report_name': u'res.partner'}], u'res.company': [{u'name': u'Preview Report', u'report_type': u'pdf', u'report_name': u'preview.report'}]}

To download a report:

>>> report = odoo.report.download('preview.report', [1])

The method will return a file-like object, you will have to read its content in order to save it on your filesystem:

>>> with open('company_preview_report.pdf', 'w') as report_file:
...     report_file.write(report.read())
...

Next step: Save your credentials (session)