summaryrefslogtreecommitdiff
path: root/addons/web/controllers
diff options
context:
space:
mode:
authorRomainLibert <rli@odoo.com>2019-09-13 10:00:34 +0000
committerRomainLibert <rli@odoo.com>2019-09-13 10:00:34 +0000
commit4c9624db9d4656457f4100ee2e848f0f81d264a9 (patch)
treeec7224b5ea896b86193f6068d3093c8168e2b638 /addons/web/controllers
parentf6d88a2e8dedec2362868fe72763284a065b0e61 (diff)
[FIX] web: add context to /report/download
This commit fixes the /report/download route in multicompany Since the multi company revamp (a5b6f31cf28e5381e1c85f66730bcdb55998e643) 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 (521f7d36c1ff929ea52e9ed6fd4170bd3b968b19) 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>
Diffstat (limited to 'addons/web/controllers')
-rw-r--r--addons/web/controllers/main.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index dfe575b8f6f..5b7eeaad62b 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -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)