odoorpc.report

This module provide the Report class to list available reports and to generate/download them.

class odoorpc.report.Report(odoo)

The Report class represents the report management service.

It provides methods to list and download available reports from the server.

Note

This service have to be used through the odoorpc.ODOO.report property.

>>> import odoorpc
>>> odoo = odoorpc.ODOO('localhost', port=8069)
>>> odoo.login('odoorpc_test', 'admin', 'password')
>>> odoo.report
<odoorpc.report.Report object at 0x7f82fe7a1d50>
download(name, ids, datas=None, context=None)

Download a report from the server and return it as a remote file.

Warning: this feature is not supported for Odoo >= 14 (CSRF token required).

For instance, to download the “Quotation / Order” report of sale orders identified by the IDs [2, 3]:

>>> report = odoo.report.download('sale.report_saleorder', [2, 3])

Write it on the file system:

>>> with open('sale_orders.pdf', 'wb') as report_file:
...     report_file.write(report.read())
...

Python 2:

Returns:

io.BytesIO

Raise:

odoorpc.error.RPCError (wrong parameters)

Raise:

ValueError (received invalid data)

Raise:

urllib2.URLError (connection error)

Python 3:

Returns:

io.BytesIO

Raise:

odoorpc.error.RPCError (wrong parameters)

Raise:

ValueError (received invalid data)

Raise:

urllib.error.URLError (connection error)

list()

List available reports from the server.

It returns a dictionary with reports classified by data model:

>>> from odoorpc.tools import v
>>> inv_model = 'account.move'
>>> if v(VERSION) < v('13.0'):
...     inv_model = 'account.invoice'
>>> odoo.report.list()[inv_model]
[{'name': u'Duplicates',
  'report_name': u'account.account_invoice_report_duplicate_main',
  'report_type': u'qweb-pdf'},
 {'name': 'Invoices',
  'report_type': 'qweb-pdf',
  'report_name': 'account.report_invoice'}]

Python 2:

Returns:

list of dictionaries

Raise:

urllib2.URLError (connection error)

Python 3:

Returns:

list of dictionaries

Raise:

urllib.error.URLError (connection error)