Skip to content

Commit

Permalink
[FIX] zpl_printer: Fixing other reports failing due to missing parameter
Browse files Browse the repository at this point in the history
if the report send is not a zpl report, it does not have a resolution, so it should not try to read one in that case.
  • Loading branch information
mohs8421 committed Sep 2, 2024
1 parent a8715f6 commit 646df3a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions zpl_printer/controllers/report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import logging

from werkzeug.urls import url_parse

Expand All @@ -10,7 +9,7 @@

from odoo.addons.web.controllers.report import ReportController

_logger = logging.getLogger(__name__)
DEFAULT_RESOLUTION = "200"


class ReportController(ReportController):
Expand All @@ -28,14 +27,13 @@ def report_download(self, data, context=None, token=None):
:returns: Response with a filetoken cookie and an attachment header
"""
requestcontent = json.loads(data)
url, report_type, resolution = (
requestcontent[0],
requestcontent[1],
requestcontent[2],
)
url, report_type = requestcontent[0], requestcontent[1]

Check warning on line 30 in zpl_printer/controllers/report.py

View check run for this annotation

Codecov / codecov/patch

zpl_printer/controllers/report.py#L29-L30

Added lines #L29 - L30 were not covered by tests
if "zpl" not in report_type:
return super().report_download(data, context=context, token=token)
try:
resolution = (

Check warning on line 34 in zpl_printer/controllers/report.py

View check run for this annotation

Codecov / codecov/patch

zpl_printer/controllers/report.py#L32-L34

Added lines #L32 - L34 were not covered by tests
requestcontent[2] if len(requestcontent) == 3 else DEFAULT_RESOLUTION
)
reportname = url.split("/report/zpl/")[1].split("?")[0]
docids = None

Check warning on line 38 in zpl_printer/controllers/report.py

View check run for this annotation

Codecov / codecov/patch

zpl_printer/controllers/report.py#L37-L38

Added lines #L37 - L38 were not covered by tests
if "/" in reportname:
Expand Down

0 comments on commit 646df3a

Please sign in to comment.