Hello all
What is the best way to get a pdf report with XML RPC from Odoo Version 16? Before Version 11 it was possible with the /report endpoint. How should this be done with the newer versions?
Thank you! Best regards
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello all
What is the best way to get a pdf report with XML RPC from Odoo Version 16? Before Version 11 it was possible with the /report endpoint. How should this be done with the newer versions?
Thank you! Best regards
Here's how you can generate a PDF report using XML-RPC in Odoo version 16:
Connect to your Odoo instance using an XML-RPC client library in your preferred programming language (e.g., Python with the xmlrpc.client module).
Call the render_report method on the report object. This method takes the following parameters:
The render_report method returns a dictionary containing the report data.
Use the received report data to save the PDF report file locally or process it further according to your requirements.
Example:
import xmlrpc.client
# Connect to Odoo instance
url = 'http://your_odoo_instance_url/xmlrpc/2/object'
db = 'your_database'
username = 'your_username'
password = 'your_password'
common = xmlrpc.client.ServerProxy('{}/common'.format(url))
uid = common.authenticate(db, username, password, {})
# Generate PDF report
report = xmlrpc.client.ServerProxy(url)
report_name = 'module_name.report_name' # Technical name of the report
doc_ids = [1, 2, 3] # IDs of the documents to include in the report
context = {} # Additional context for report generation
report_data = report.render_report(db, uid, password, report_name, doc_ids, context)
# Save the PDF report locally
with open('report.pdf', 'wb') as f:
f.write(report_data['result'])
Make sure to replace 'your_odoo_instance_url', 'your_database', 'your_username', 'your_password', 'module_name.report_name', and [1, 2, 3] with the appropriate values for your Odoo instance and report.
getting error
xmlrpc.client.Fault: <Fault 1: 'Traceback (most recent call last):\n File "/mnt/c/Others/odoo16/odoo/addons/base/controllers/rpc.py", line 150, in xmlrpc_2\n response = self._xmlrpc(service)\n File "/mnt/c/Others/odoo16/odoo/addons/base/controllers/rpc.py", line 130, in _xmlrpc\n result = dispatch_rpc(service, method, params)\n File "/mnt/c/Others/odoo16/odoo/http.py", line 366, in dispatch_rpc\n return dispatch(method, params)\n File "/mnt/c/Others/odoo16/odoo/service/model.py", line 39, in dispatch\n raise NameError("Method not available %s" % method)\nNameError: Method not available render_report\n'>
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký
Dear Shubham
Thanks for your answer. Unfortunately this does not work, I get the following error: