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

[14.0]Download report is not possible because of private _render method #65

Open flotho opened 2 years ago

flotho commented 2 years ago

In v14, Odoo turn the public render method as private : https://github.com/OCA/OCB/commit/d9287caf9408bb4ff85ad734cbca08e44321e205#diff-7ce69a093ea1fb1cf2989e24d52cb8e717ab4f2b3c2006ba5cc67503a3df1aff gives this new signature : https://github.com/OCA/OCB/blob/14.0/odoo/addons/base/models/ir_actions_report.py#L871

Trying to download a report throws this issue :

   report = odoo.report.download('stock.report_deliveryslip', [2, ])
  File "/home/florent.thomas/.local/lib/python3.8/site-packages/odoorpc/report.py", line 118, in download
    response = report.with_context(context)._render(
  File "/home/florent.thomas/.local/lib/python3.8/site-packages/odoorpc/models.py", line 389, in __getattr__
    return super(Model, self).__getattr__(method)
AttributeError: 'super' object has no attribute '__getattr__'

@MiquelRForgeFlow , how do you succeed to make this work : https://github.com/OCA/odoorpc/commit/187853abe2e1e0873468475b7f2f370cd603ba80#diff-891d7fc45dba1b16d043072a3d345c82fdecfd4e466ee9d90c0288c32dfc2ccfR118 Is there any workaround from your point of view ?

flotho commented 2 years ago

https://github.com/odoo/odoo/issues/78528

MiquelRForgeFlow commented 2 years ago

how do you succeed to make this work

I didn't. See https://github.com/OCA/odoorpc/pull/60#issuecomment-806706025, when @sebalix said:

Regarding the issue for v14 _render, we could try to use the HTTP controller to generate the report if possible.
flotho commented 2 years ago

do you mean the idea is to generate a crsf token and then call a report url ?

tejastank commented 2 years ago

odoo 14

def render(self, res_ids, data=None):
    print("asdfadsf")
    report_type = self.report_type.lower().replace('-', '_')
    render_func = getattr(self, '_render_' + report_type, None)
    if not render_func:
        return None
    return render_func(res_ids, data=data)

we added in odoo branch code, ir_actions_report.py, next to _render, we added this code and its resolve for us, until official team resolve

Hope this will helps someone have urgency

regards, tejas Xamta Infotech - xamta.in snippetbucket.com (Previous Trade Name)

sebalix commented 1 year ago

Yes this still need to be addressed, I wanted to grab the CSRF token from the login web page for instance and use it for methods that required one starting from Odoo 14.0. Will try to implement this for release v0.10.0.

AnaelMobilia commented 1 year ago

@sebalix Have you found any idea on how to grab the CSRF token for this issue ?

Bests regards, Anael

flotho commented 7 months ago

for the record : https://github.com/OCA/odoorpc/issues/88#issuecomment-1907870776