forked from OCA/survey
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (30 loc) · 1.23 KB
/
main.py
File metadata and controls
33 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.http import content_disposition, request
from odoo.addons.survey.controllers.main import Survey
class Survey(Survey):
def _generate_report(self, user_input, download=True):
if not user_input.py3o_template_id:
return super()._generate_report(user_input, download=download)
report = (
request.env["ir.actions.report"]
.sudo()
._render_py3o(
"survey_certification_py3o.custom_certification_report",
[user_input.id],
data={"report_type": "pdf"},
)[0]
)
report_content_disposition = content_disposition("Certification.pdf")
if not download:
content_split = report_content_disposition.split(";")
content_split[0] = "inline"
report_content_disposition = ";".join(content_split)
return request.make_response(
report,
headers=[
("Content-Type", "application/pdf"),
("Content-Length", len(report)),
("Content-Disposition", report_content_disposition),
],
)