Open NateLeeg96 opened 1 year ago
maybe this cold be the beginning of an explanation : https://github.com/odoo-java/odoo-java-api/issues/17
In fact it's not possible anymore since Odoo 14.0.
Things are:
/jsonrpc
endpoint (instead of /web/session/authenticate
) after Odoo 10.0 to authenticate, this allows users to use API key for instance which is an important feature/jsonrpc
endpoint doesn't generate a user's session like the web client does, so that a GET HTTP request on the homepage with OdooRPC would allow to retrieve the CSRF tokenSo 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.
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
Would it make sense to implement the call to the following URL /report/pdf/
sure @pfranck but we still stucked on getting a proper connexion to avoid crsf issues ;-)
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())
Great thanks to you @em230418 I'll test this ASAP
With Odoo Version 16 reports cannot be downloaded.
Steps to reproduce the behavior:
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'