Report Printing¶
Available reports can be listed by searching the ir.actions.report
model, fields of interest being
- model
- the model on which the report applies, can be used to look for available reports on a specific model
- name
- human-readable report name
- report_name
- the technical name of the report, used to print it
Reports can be printed using restapi/1.0/report
endpoint over REST API with the following information:
- the name of the report (
report_name
)- the single record id or ids of the records to include in the report
Note
API endpoints:
- GET {your_Odoo_server_url}/restapi/1.0/report/{report_name}/{id} (Print Single Report)
- GET {your_Odoo_server_url}/restapi/1.0/report/{report_name}?ids={comma_separated_ids} (Print Report Set)
Print Single Report¶
Report can be printed by giving the name of the report(report_name
) and a single record id.
-
GET
/restapi/1.0/report/{report_name}/{id}
¶ Request:
Warning
this example needs
account
module installedGET /restapi/1.0/report/account.report_invoice/12 HTTP/1.1 Host: {your_Odoo_server_url}
Response:
Note
the report is sent as PDF binary data encoded in base64, it must be decoded and may need to be saved to disk before use
HTTP/1.1 200 OK { 'report': { 'id': 12, 'state': 'true', 'format': 'pdf', 'result': 'R0lGODlhbgCMAPf\/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p\ /nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\n KKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR+3WwMqEWenN\n sZYxL\/Ddy\/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\n NsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\n osFaS+TBnK4kKti5sNaYg\/z49aqYl5kqLrljUtORfMOlo\/36+H4ZH ... ... ...' } }
Request Headers: - Accept – the response content type depends on Accept header
- Authorization – The OAuth protocol parameters to authenticate.
Response Headers: - Content-Type – this depends on Accept header of request
Status Codes: - 200 OK – no error
- 404 Not Found – there’s no resource
- 401 Unauthorized – authentication failed
- 403 Forbidden – if any error raise
Print List Reports¶
Report can be printed by giving the name of the report(report_name
) and a list of records.
-
GET
/restapi/1.0/report/{report_name}?ids={comma_separated_ids}
¶ Request:
Warning
this example needs
account
module installedGET /restapi/1.0/report/account.report_invoice?ids=12,17 HTTP/1.1 Host: {your_Odoo_server_url}
Response:
Note
the report is sent as PDF binary data encoded in base64, it must be decoded and may need to be saved to disk before use
HTTP/1.1 200 OK { 'report': [ { 'id': 12, 'state': 'true', 'format': 'pdf', 'result': 'R0lGODlhbgCMAPf\/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p\ /nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\n KKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR+3WwMqEWenN\n sZYxL\/Ddy\/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\n NsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\n osFaS+TBnK4kKti5sNaYg\/z49aqYl5kqLrljUtORfMOlo\/36+H4ZH ... ... ...' }, { 'id': 17, 'state': 'true', 'format': 'pdf', 'result': '9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ+jKvrAlK6AhJ65A\nMp MpKuC3j5obIsRwS7hAN8l\/YtvDvnYXHbAoLI47SIUsOMenorF4gO\/m4+fH\npo4vLZ8oKMukqp0cJbhVSMV2U uPR0bAfMLIrLrg\/OcJwT8h+Vt+wn8eurLlh\nQrIfKHQOHHQOHf\/\/\/\/\/ \/\/yH5BAEAAP8ALAAAAABuAIwAAAj\/AP8JHDhQXjpz\n\/PopXNiPn0OHDRMmbKhQIsOJFS1SxAhxI 8SHFzVeDBnx48iNBAeeOkcxokeX\nFRdOnAlSokaaLXNujJkxo8iYHRkKtWkzZ SsaOXkAWsoUECynsHgoqEW1q ... ... ...' } ] }
Request Headers: - Accept – the response content type depends on Accept header
- Authorization – The OAuth protocol parameters to authenticate.
Response Headers: - Content-Type – this depends on Accept header of request
Status Codes: - 200 OK – no error
- 404 Not Found – there’s no resource
- 401 Unauthorized – authentication failed
- 403 Forbidden – if any error raise