mirror of
https://github.com/bringout/oca-report.git
synced 2026-04-23 22:02:00 +02:00
update: report_xlsx to OCA 19.0 version (19.0.1.0.2)
🤖 assisted by claude
This commit is contained in:
parent
8566ac3819
commit
32a4fa90f7
23 changed files with 201 additions and 206 deletions
|
|
@ -11,6 +11,8 @@ from odoo.http import (
|
|||
content_disposition,
|
||||
request,
|
||||
route,
|
||||
)
|
||||
from odoo.http import (
|
||||
serialize_exception as _serialize_exception,
|
||||
)
|
||||
from odoo.tools import html_escape
|
||||
|
|
@ -40,8 +42,7 @@ class ReportController(ReportController):
|
|||
xlsxhttpheaders = [
|
||||
(
|
||||
"Content-Type",
|
||||
"application/vnd.openxmlformats-"
|
||||
"officedocument.spreadsheetml.sheet",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
),
|
||||
("Content-Length", len(xlsx)),
|
||||
]
|
||||
|
|
@ -49,7 +50,7 @@ class ReportController(ReportController):
|
|||
return super().report_routes(reportname, docids, converter, **data)
|
||||
|
||||
@route()
|
||||
def report_download(self, data, context=None, token=None):
|
||||
def report_download(self, data, context=None, token=None, readonly=True):
|
||||
requestcontent = json.loads(data)
|
||||
url, report_type = requestcontent[0], requestcontent[1]
|
||||
if report_type == "xlsx":
|
||||
|
|
@ -69,8 +70,9 @@ class ReportController(ReportController):
|
|||
url_decode(url.split("?")[1]).items()
|
||||
) # decoding the args represented in JSON
|
||||
if "context" in data:
|
||||
context, data_context = json.loads(context or "{}"), json.loads(
|
||||
data.pop("context")
|
||||
context, data_context = (
|
||||
json.loads(context or "{}"),
|
||||
json.loads(data.pop("context")),
|
||||
)
|
||||
context = json.dumps({**context, **data_context})
|
||||
response = self.report_routes(
|
||||
|
|
@ -80,7 +82,7 @@ class ReportController(ReportController):
|
|||
report = request.env["ir.actions.report"]._get_report_from_name(
|
||||
reportname
|
||||
)
|
||||
filename = "%s.%s" % (report.name, "xlsx")
|
||||
filename = f"{report.name}.xlsx"
|
||||
|
||||
if docids:
|
||||
ids = [int(x) for x in docids.split(",")]
|
||||
|
|
@ -89,7 +91,7 @@ class ReportController(ReportController):
|
|||
report_name = safe_eval(
|
||||
report.print_report_name, {"object": obj, "time": time}
|
||||
)
|
||||
filename = "%s.%s" % (report_name, "xlsx")
|
||||
filename = f"{report_name}.xlsx"
|
||||
if not response.headers.get("Content-Disposition"):
|
||||
response.headers.add(
|
||||
"Content-Disposition", content_disposition(filename)
|
||||
|
|
@ -101,4 +103,6 @@ class ReportController(ReportController):
|
|||
error = {"code": 200, "message": "Odoo Server Error", "data": se}
|
||||
return request.make_response(html_escape(json.dumps(error)))
|
||||
else:
|
||||
return super().report_download(data, context=context, token=token)
|
||||
return super().report_download(
|
||||
data, context, token=token, readonly=readonly
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue