Skip to content

Commit

Permalink
[MIG] report_csv: Migration to 17.0
Browse files Browse the repository at this point in the history
TT52352
  • Loading branch information
victoralmau committed Feb 21, 2025
1 parent bfcb3a4 commit 3a65815
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion report_csv/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Creu Blanca, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"category": "Reporting",
"version": "16.0.2.1.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["base", "web"],
"demo": ["demo/report.xml"],
Expand Down
8 changes: 4 additions & 4 deletions report_csv/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def report_routes(self, reportname, docids=None, converter=None, **data):
return super().report_routes(reportname, docids, converter, **data)

@route()
def report_download(self, data, context=None):
def report_download(self, data, context=None, token=None):
requestcontent = json.loads(data)
url, report_type = requestcontent[0], requestcontent[1]
reportname = ""
Expand Down Expand Up @@ -85,7 +85,7 @@ def report_download(self, data, context=None):
report = request.env["ir.actions.report"]._get_report_from_name(
reportname
)
filename = "%s.%s" % (report.name, "csv")
filename = f"{report.name}.csv"

if docids:
ids = [int(x) for x in docids.split(",")]
Expand All @@ -94,13 +94,13 @@ def report_download(self, data, context=None):
report_name = safe_eval(

Check warning on line 94 in report_csv/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

report_csv/controllers/main.py#L94

Added line #L94 was not covered by tests
report.print_report_name, {"object": obj, "time": time}
)
filename = "%s.%s" % (report_name, "csv")
filename = f"{report_name}.csv"

Check warning on line 97 in report_csv/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

report_csv/controllers/main.py#L97

Added line #L97 was not covered by tests
response.headers.add(
"Content-Disposition", content_disposition(filename)
)
return response
else:
return super().report_download(data, context)
return super().report_download(data, context, token)
except Exception as e:
_logger.exception("Error while generating report %s", reportname)
se = _serialize_exception(e)
Expand Down
10 changes: 2 additions & 8 deletions report_csv/views/ir_actions_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
<field name="inherit_id" ref="base.act_report_xml_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='report_type']" position="after">
<field
name="encoding"
attrs="{'invisible': [('report_type', '!=', 'csv')]}"
/>
<field
name="encode_error_handling"
attrs="{'invisible': [('encoding', '=', False)]}"
/>
<field name="encoding" invisible="report_type!='csv'" />
<field name="encode_error_handling" invisible="not encoding" />
</xpath>
</field>
</record>
Expand Down

0 comments on commit 3a65815

Please sign in to comment.