OCA / odoorpc

Python module to pilot your Odoo servers through JSON-RPC.
http://pythonhosted.org/OdooRPC/
GNU Lesser General Public License v3.0
231 stars 123 forks source link

Report cannot be generated in Odoo 16 #88

Open NateLeeg96 opened 1 year ago

NateLeeg96 commented 1 year ago

With Odoo Version 16 reports cannot be downloaded.

Steps to reproduce the behavior:

  1. report = odoo.report.download('TEMPLATE_NAME', ID)
  2. Traceback (most recent call last): File "main.py", line 10, in report = odoo.report.download('lg_reports.rechnung_qr_report_template', 1650) File "/home/pi/.local/lib/python3.5/site-packages/odoorpc/report.py", line 133, in download response = report.with_context(context).render(ids, data=datas) File "/home/pi/.local/lib/python3.5/site-packages/odoorpc/models.py", line 405, in rpc_method self._name, method, args, kwargs) File "/home/pi/.local/lib/python3.5/site-packages/odoorpc/odoo.py", line 486, in execute_kw 'args': args_to_send}) File "/home/pi/.local/lib/python3.5/site-packages/odoorpc/odoo.py", line 285, in json data['error']) odoorpc.error.RPCError: type object 'ir.actions.report' has no attribute 'render'

flotho commented 1 year ago

maybe this cold be the beginning of an explanation : https://github.com/odoo-java/odoo-java-api/issues/17

sebalix commented 1 year ago

In fact it's not possible anymore since Odoo 14.0.

Things are:

So we will probably need to still call /web/session/authenticate (to get this CSRF token) to workaround this, but it's just an idea, I really don't know if we could face other caveats.

flotho commented 1 year ago

maybe we could work with access_token provided by potal_mixin : https://github.com/odoo/odoo/blob/16.0/addons/portal/models/portal_mixin.py#L15 yet this will not be applied on models not available in portal

flotho commented 10 months ago

65

pfranck commented 8 months ago

Would it make sense to implement the call to the following URL /report/pdf// as explained in the documentation (https://www.odoo.com/documentation/15.0/developer/reference/backend/reports.html#reports-are-web-pages) One of the draw back would be that we need to call the API for each IDs

flotho commented 8 months ago

sure @pfranck but we still stucked on getting a proper connexion to avoid crsf issues ;-)

em230418 commented 7 months ago
import odoorpc

# Prepare the connection to the server
odoo = odoorpc.ODOO('myserver.odoo.com', port=443, protocol='jsonrpc+ssl')

db = "dbname"
username = "admin"
password = "admin"

# Login
odoo.json("/web/session/authenticate", {"db": db, "login": username, "password": password})

r = odoo.http("/report/pdf/account.report_invoice/15781")
assert r.status == 200
with open("report.pdf", "wb") as f:
    f.write(r.read())
flotho commented 7 months ago

Great thanks to you @em230418 I'll test this ASAP