Skip to content

Commit 2882f9e

Browse files
committed
[FIX] stock_card_report: pre-commit auto fixes
1 parent e308c08 commit 2882f9e

File tree

3 files changed

+54
-49
lines changed

3 files changed

+54
-49
lines changed

stock_card_report/controllers/main.py

+47-44
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
1-
# -*- coding: utf-8 -*-
2-
import werkzeug
3-
from werkzeug.exceptions import InternalServerError
4-
from io import BytesIO
51
from odoo import http
62
from odoo.http import request
7-
from odoo.tools.misc import html_escape
8-
9-
import json
103

114

125
class StockCardReportController(http.Controller):
13-
14-
@http.route('/stock/stock_card_report/<string:output_format>', type='http', auth='user')
15-
def report(self, output_format, report_name=False, **kw):
16-
if output_format == 'pdf':
17-
report_ref = request.env.ref('stock_card_report.action_stock_card_report_pdf')
18-
method_name = '_render_qweb_pdf'
19-
report = getattr(report_ref, method_name)(
20-
report_ref,
21-
res_ids=[int(kw['active_id'])],
22-
data={
23-
'report_type': 'pdf'
24-
},
25-
)[0]
26-
return request.make_response(
27-
report,
28-
headers=[
29-
('Content-Type', 'application/pdf'),
30-
('Content-Disposition', f'attachment; filename= Stock_Card_Report.pdf'),
31-
],
32-
)
33-
else:
34-
report_ref = request.env.ref('stock_card_report.action_stock_card_report_xlsx')
35-
method_name = '_render_xlsx'
36-
report = getattr(report_ref, method_name)(
37-
report_ref,
38-
docids=[int(kw['active_id'])],
39-
data={
40-
'report_type': 'xlsx'
41-
},
42-
)[0]
43-
return request.make_response(
44-
report,
45-
headers=[
46-
('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
47-
('Content-Disposition', 'attachment; filename= Stock_Card_Report.xlsx'),
48-
],
49-
)
6+
@http.route(
7+
"/stock/stock_card_report/<string:output_format>", type="http", auth="user"
8+
)
9+
def report(self, output_format, report_name=False, **kw):
10+
if output_format == "pdf":
11+
report_ref = request.env.ref(
12+
"stock_card_report.action_stock_card_report_pdf"
13+
)
14+
method_name = "_render_qweb_pdf"
15+
report = getattr(report_ref, method_name)(
16+
report_ref,
17+
res_ids=[int(kw["active_id"])],
18+
data={"report_type": "pdf"},
19+
)[0]
20+
return request.make_response(
21+
report,
22+
headers=[
23+
("Content-Type", "application/pdf"),
24+
(
25+
"Content-Disposition",
26+
"attachment; filename= Stock_Card_Report.pdf",
27+
),
28+
],
29+
)
30+
else:
31+
report_ref = request.env.ref(
32+
"stock_card_report.action_stock_card_report_xlsx"
33+
)
34+
method_name = "_render_xlsx"
35+
report = getattr(report_ref, method_name)(
36+
report_ref,
37+
docids=[int(kw["active_id"])],
38+
data={"report_type": "xlsx"},
39+
)[0]
40+
return request.make_response(
41+
report,
42+
headers=[
43+
(
44+
"Content-Type",
45+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
46+
),
47+
(
48+
"Content-Disposition",
49+
"attachment; filename= Stock_Card_Report.xlsx",
50+
),
51+
],
52+
)

stock_card_report/static/description/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
<?xml version="1.0" encoding="utf-8"?>
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
33
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
44
<head>

stock_card_report/static/src/js/stock_card_report_backend.xml

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
<t t-name="report_buttons">
88
<div class="button_row">
99
<button
10-
class="o_stock_card_reports_print btn btn-sm oe_button"
11-
t-on-click="() => this.onClickPrint()">
10+
class="o_stock_card_reports_print btn btn-sm oe_button"
11+
t-on-click="() => this.onClickPrint()"
12+
>
1213
<span class="fa fa-print" />
1314
Print
1415
</button>
1516
<button
16-
class="o_stock_card_reports_export btn btn-sm oe_button"
17-
t-on-click="() => this.onClickExport()">
17+
class="o_stock_card_reports_export btn btn-sm oe_button"
18+
t-on-click="() => this.onClickExport()"
19+
>
1820
<span class="fa fa-download" />
1921
Export
2022
</button>

0 commit comments

Comments
 (0)