Skip to content

Commit bfcb3a4

Browse files
committed
[IMP] report_csv: pre-commit auto fixes
1 parent 6e85d0b commit bfcb3a4

File tree

12 files changed

+106
-88
lines changed

12 files changed

+106
-88
lines changed

report_csv/README.rst

+58-50
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Base report csv
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
20-
:target: https://github.com/OCA/reporting-engine/tree/16.0/report_csv
20+
:target: https://github.com/OCA/reporting-engine/tree/17.0/report_csv
2121
:alt: OCA/reporting-engine
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_csv
23+
:target: https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-report_csv
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=17.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -38,57 +38,65 @@ This module provides a basic report class to generate csv report.
3838
Configuration
3939
=============
4040

41-
In case the exported CSV report should be encoded in another system than UTF-8, following
42-
fields of the report record (*Settings > Technical > Reports*) should be populated accordingly.
41+
In case the exported CSV report should be encoded in another system than
42+
UTF-8, following fields of the report record (*Settings > Technical >
43+
Reports*) should be populated accordingly.
4344

44-
* Encoding: set an encoding system (such as cp932)
45-
* Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
45+
- Encoding: set an encoding system (such as cp932)
46+
- Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
4647

47-
* 'Ignore': in case of an encoding error, the problematic character will be removed from the exported file.
48-
* 'Replace': in case of an encoding error, the problematic character will be replaced with '?' symbol.
49-
* Leaving the field blank: in case of an encoding error, the report generation fails with an error message.
48+
- 'Ignore': in case of an encoding error, the problematic character
49+
will be removed from the exported file.
50+
- 'Replace': in case of an encoding error, the problematic character
51+
will be replaced with '?' symbol.
52+
- Leaving the field blank: in case of an encoding error, the report
53+
generation fails with an error message.
5054

5155
Usage
5256
=====
5357

54-
An example of CSV report for partners on a module called `module_name`:
58+
An example of CSV report for partners on a module called
59+
\`module_name\`:
5560

56-
A python class ::
61+
A python class :
5762

58-
from odoo import models
63+
::
5964

60-
class PartnerCSV(models.AbstractModel):
61-
_name = 'report.report_csv.partner_csv'
62-
_inherit = 'report.report_csv.abstract'
65+
from odoo import models
6366

64-
def generate_csv_report(self, writer, data, partners):
65-
writer.writeheader()
66-
for obj in partners:
67-
writer.writerow({
68-
'name': obj.name,
69-
'email': obj.email,
70-
})
67+
class PartnerCSV(models.AbstractModel):
68+
_name = 'report.report_csv.partner_csv'
69+
_inherit = 'report.report_csv.abstract'
7170

72-
def csv_report_options(self):
73-
res = super().csv_report_options()
74-
res['fieldnames'].append('name')
75-
res['fieldnames'].append('email')
76-
res['delimiter'] = ';'
77-
res['quoting'] = csv.QUOTE_ALL
78-
return res
71+
def generate_csv_report(self, writer, data, partners):
72+
writer.writeheader()
73+
for obj in partners:
74+
writer.writerow({
75+
'name': obj.name,
76+
'email': obj.email,
77+
})
7978

79+
def csv_report_options(self):
80+
res = super().csv_report_options()
81+
res['fieldnames'].append('name')
82+
res['fieldnames'].append('email')
83+
res['delimiter'] = ';'
84+
res['quoting'] = csv.QUOTE_ALL
85+
return res
8086

81-
A report XML record ::
87+
A report XML record :
8288

83-
<report
84-
id="partner_csv"
85-
model="res.partner"
86-
string="Print to CSV"
87-
report_type="csv"
88-
name="module_name.report_name"
89-
file="res_partner"
90-
attachment_use="False"
91-
/>
89+
::
90+
91+
<report
92+
id="partner_csv"
93+
model="res.partner"
94+
string="Print to CSV"
95+
report_type="csv"
96+
name="module_name.report_name"
97+
file="res_partner"
98+
attachment_use="False"
99+
/>
92100

93101
Update encoding with an appropriate value (e.g. cp932) as necessary.
94102

@@ -98,30 +106,30 @@ Bug Tracker
98106
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
99107
In case of trouble, please check there if your issue has already been reported.
100108
If you spotted it first, help us to smash it by providing a detailed and welcomed
101-
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
109+
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
102110

103111
Do not contact contributors directly about support or help with technical issues.
104112

105113
Credits
106114
=======
107115

108116
Authors
109-
~~~~~~~
117+
-------
110118

111119
* Creu Blanca
112120

113121
Contributors
114-
~~~~~~~~~~~~
122+
------------
115123

116-
* Enric Tobella <[email protected]>
117-
* Jaime Arroyo <[email protected]>
118-
* Rattapong Chokmasermkul <[email protected]>
119-
* `Quartile <https://www.quartile.co>`__:
124+
- Enric Tobella <[email protected]>
125+
- Jaime Arroyo <[email protected]>
126+
- Rattapong Chokmasermkul <[email protected]>
127+
- `Quartile <https://www.quartile.co>`__:
120128

121-
* Aung Ko Ko Lin
129+
- Aung Ko Ko Lin
122130

123131
Maintainers
124-
~~~~~~~~~~~
132+
-----------
125133

126134
This module is maintained by the OCA.
127135

@@ -133,6 +141,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
133141
mission is to support the collaborative development of Odoo features and
134142
promote its widespread use.
135143

136-
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/report_csv>`_ project on GitHub.
144+
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/17.0/report_csv>`_ project on GitHub.
137145

138146
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

report_csv/controllers/main.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
content_disposition,
1212
request,
1313
route,
14+
)
15+
from odoo.http import (
1416
serialize_exception as _serialize_exception,
1517
)
1618
from odoo.tools import html_escape
@@ -47,9 +49,7 @@ def report_routes(self, reportname, docids=None, converter=None, **data):
4749
("Content-Length", len(csv)),
4850
]
4951
return request.make_response(csv, headers=csvhttpheaders)
50-
return super(ReportController, self).report_routes(
51-
reportname, docids, converter, **data
52-
)
52+
return super().report_routes(reportname, docids, converter, **data)
5353

5454
@route()
5555
def report_download(self, data, context=None):
@@ -73,8 +73,9 @@ def report_download(self, data, context=None):
7373
url_decode(url.split("?")[1]).items()
7474
) # decoding the args represented in JSON
7575
if "context" in data:
76-
context, data_context = json.loads(context or "{}"), json.loads(
77-
data.pop("context")
76+
context, data_context = (
77+
json.loads(context or "{}"),
78+
json.loads(data.pop("context")),
7879
)
7980
context = json.dumps({**context, **data_context})
8081
response = self.report_routes(
@@ -99,7 +100,7 @@ def report_download(self, data, context=None):
99100
)
100101
return response
101102
else:
102-
return super(ReportController, self).report_download(data, context)
103+
return super().report_download(data, context)
103104
except Exception as e:
104105
_logger.exception("Error while generating report %s", reportname)
105106
se = _serialize_exception(e)

report_csv/models/ir_report.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _render_csv(self, report_ref, docids, data):
8080

8181
@api.model
8282
def _get_report_from_name(self, report_name):
83-
res = super(ReportAction, self)._get_report_from_name(report_name)
83+
res = super()._get_report_from_name(report_name)
8484
if res:
8585
return res
8686
report_obj = self.env["ir.actions.report"]

report_csv/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"

report_csv/readme/CONFIGURE.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
In case the exported CSV report should be encoded in another system than
2+
UTF-8, following fields of the report record (*Settings \> Technical \>
3+
Reports*) should be populated accordingly.
4+
5+
- Encoding: set an encoding system (such as cp932)
6+
- Encode Error Handling: select 'Ignore' or 'Replace' as necessary.
7+
- 'Ignore': in case of an encoding error, the problematic character
8+
will be removed from the exported file.
9+
- 'Replace': in case of an encoding error, the problematic character
10+
will be replaced with '?' symbol.
11+
- Leaving the field blank: in case of an encoding error, the report
12+
generation fails with an error message.

report_csv/readme/CONFIGURE.rst

-9
This file was deleted.

report_csv/readme/CONTRIBUTORS.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- Enric Tobella \<<[email protected]>\>
2+
- Jaime Arroyo \<<[email protected]>\>
3+
- Rattapong Chokmasermkul \<<[email protected]>\>
4+
- [Quartile](https://www.quartile.co):
5+
- Aung Ko Ko Lin

report_csv/readme/CONTRIBUTORS.rst

-6
This file was deleted.
File renamed without changes.

report_csv/readme/USAGE.rst report_csv/readme/USAGE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
An example of CSV report for partners on a module called `module_name`:
1+
An example of CSV report for partners on a module called
2+
\`module_name\`:
23

3-
A python class ::
4+
A python class :
45

56
from odoo import models
67

@@ -24,8 +25,7 @@ A python class ::
2425
res['quoting'] = csv.QUOTE_ALL
2526
return res
2627

27-
28-
A report XML record ::
28+
A report XML record :
2929

3030
<report
3131
id="partner_csv"

report_csv/static/description/index.html

+16-11
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Base report csv</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:a39959a00912416454f8818d70b9a3ffdd305aeb1b1c35ce3ea007f3c41526bd
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/16.0/report_csv"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_csv"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/17.0/report_csv"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-report_csv"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module provides a basic report class to generate csv report.</p>
374374
<p><strong>Table of contents</strong></p>
375375
<div class="contents local topic" id="contents">
@@ -387,22 +387,27 @@ <h1 class="title">Base report csv</h1>
387387
</div>
388388
<div class="section" id="configuration">
389389
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
390-
<p>In case the exported CSV report should be encoded in another system than UTF-8, following
391-
fields of the report record (<em>Settings &gt; Technical &gt; Reports</em>) should be populated accordingly.</p>
390+
<p>In case the exported CSV report should be encoded in another system than
391+
UTF-8, following fields of the report record (<em>Settings &gt; Technical &gt;
392+
Reports</em>) should be populated accordingly.</p>
392393
<ul class="simple">
393394
<li>Encoding: set an encoding system (such as cp932)</li>
394395
<li>Encode Error Handling: select ‘Ignore’ or ‘Replace’ as necessary.<ul>
395-
<li>‘Ignore’: in case of an encoding error, the problematic character will be removed from the exported file.</li>
396-
<li>‘Replace’: in case of an encoding error, the problematic character will be replaced with ‘?’ symbol.</li>
397-
<li>Leaving the field blank: in case of an encoding error, the report generation fails with an error message.</li>
396+
<li>‘Ignore’: in case of an encoding error, the problematic character
397+
will be removed from the exported file.</li>
398+
<li>‘Replace’: in case of an encoding error, the problematic character
399+
will be replaced with ‘?’ symbol.</li>
400+
<li>Leaving the field blank: in case of an encoding error, the report
401+
generation fails with an error message.</li>
398402
</ul>
399403
</li>
400404
</ul>
401405
</div>
402406
<div class="section" id="usage">
403407
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
404-
<p>An example of CSV report for partners on a module called <cite>module_name</cite>:</p>
405-
<p>A python class</p>
408+
<p>An example of CSV report for partners on a module called
409+
`module_name`:</p>
410+
<p>A python class :</p>
406411
<pre class="literal-block">
407412
from odoo import models
408413

@@ -426,7 +431,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
426431
res['quoting'] = csv.QUOTE_ALL
427432
return res
428433
</pre>
429-
<p>A report XML record</p>
434+
<p>A report XML record :</p>
430435
<pre class="literal-block">
431436
&lt;report
432437
id=&quot;partner_csv&quot;
@@ -445,7 +450,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
445450
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
446451
In case of trouble, please check there if your issue has already been reported.
447452
If you spotted it first, help us to smash it by providing a detailed and welcomed
448-
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
453+
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_csv%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
449454
<p>Do not contact contributors directly about support or help with technical issues.</p>
450455
</div>
451456
<div class="section" id="credits">
@@ -477,7 +482,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
477482
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
478483
mission is to support the collaborative development of Odoo features and
479484
promote its widespread use.</p>
480-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/report_csv">OCA/reporting-engine</a> project on GitHub.</p>
485+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/17.0/report_csv">OCA/reporting-engine</a> project on GitHub.</p>
481486
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
482487
</div>
483488
</div>

report_csv/tests/test_report.py

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def test_attachment_use(self):
6262
self.assertTupleEqual(rep, rep_from_attachment)
6363

6464
def test_id_retrieval(self):
65-
6665
# Typical call from WebUI with wizard
6766
objs = self.csv_report._get_objs_for_report(
6867
False, {"context": {"active_ids": self.docs.ids}}

0 commit comments

Comments
 (0)