[FIX] web: add context to /report/download
This commit fixes the /report/download route in multicompany Since the multi company revamp (a5b6f31cf2) the multi company rules depend on the context. However the route /report/download was not forwarding any context, this meant that when trying to read some fields on a record in a company that is different than the default one, it would crash with the multi company ir.rule Forwarding the context from the session in the Javascript call is quite simple however since (521f7d36c1) it also requires to change the signature of the `report_download` method in order to pass the context to the final method. As there was already some code allowing the adding of some context in `report_routes` this PR reuses this code by simply passing the context as a kwargs. closes odoo/odoo#36839 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -1805,7 +1805,7 @@ class ReportController(http.Controller):
|
||||
return request.make_response(barcode, headers=[('Content-Type', 'image/png')])
|
||||
|
||||
@http.route(['/report/download'], type='http', auth="user")
|
||||
def report_download(self, data, token):
|
||||
def report_download(self, data, token, context=None):
|
||||
"""This function is used by 'action_manager_report.js' in order to trigger the download of
|
||||
a pdf/controller report.
|
||||
|
||||
@@ -1829,11 +1829,11 @@ class ReportController(http.Controller):
|
||||
|
||||
if docids:
|
||||
# Generic report:
|
||||
response = self.report_routes(reportname, docids=docids, converter=converter)
|
||||
response = self.report_routes(reportname, docids=docids, converter=converter, context=context)
|
||||
else:
|
||||
# Particular report:
|
||||
data = url_decode(url.split('?')[1]).items() # decoding the args represented in JSON
|
||||
response = self.report_routes(reportname, converter=converter, **dict(data))
|
||||
response = self.report_routes(reportname, converter=converter, context=context, **dict(data))
|
||||
|
||||
report = request.env['ir.actions.report']._get_report_from_name(reportname)
|
||||
filename = "%s.%s" % (report.name, extension)
|
||||
|
||||
@@ -51,6 +51,7 @@ ActionManager.include({
|
||||
url: '/report/download',
|
||||
data: {
|
||||
data: JSON.stringify([url, type]),
|
||||
context: JSON.stringify(session.user_context),
|
||||
},
|
||||
success: resolve,
|
||||
error: (error) => {
|
||||
|
||||
Reference in New Issue
Block a user