Skip to content

Commit 1d16253

Browse files
committed
[IMP] printer_zpl2: pre-commit auto fixes
1 parent f7efd3c commit 1d16253

15 files changed

+167
-159
lines changed

Diff for: printer_zpl2/README.rst

+55-46
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@ Printer ZPL II
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%2Freport--print--send-lightgray.png?logo=github
20-
:target: https://github.com/OCA/report-print-send/tree/16.0/printer_zpl2
20+
:target: https://github.com/OCA/report-print-send/tree/17.0/printer_zpl2
2121
:alt: OCA/report-print-send
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/report-print-send-16-0/report-print-send-16-0-printer_zpl2
23+
:target: https://translation.odoo-community.org/projects/report-print-send-17-0/report-print-send-17-0-printer_zpl2
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/report-print-send&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=17.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

31-
This module extends the **Report to printer** (``base_report_to_printer``)
32-
module to add a ZPL II label printing feature.
31+
This module extends the **Report to printer**
32+
(``base_report_to_printer``) module to add a ZPL II label printing
33+
feature.
3334

34-
This module is meant to be used as a base for module development, and does not provide a GUI on its own.
35-
See below for more details.
35+
This module is meant to be used as a base for module development, and
36+
does not provide a GUI on its own. See below for more details.
3637

3738
**Table of contents**
3839

@@ -49,84 +50,92 @@ Configuration
4950

5051
To configure this module, you need to:
5152

52-
#. Go to *Settings > Printing > Labels > ZPL II*
53-
#. Create new labels
54-
#. Import ZPL2 code
55-
#. Use the Test Mode tab during the creation
53+
1. Go to *Settings > Printing > Labels > ZPL II*
54+
2. Create new labels
55+
3. Import ZPL2 code
56+
4. Use the Test Mode tab during the creation
5657

57-
It's also possible to add a label printing wizard on any model by creating a new *ir.actions.act_window* record.
58-
For example, to add the printing wizard on the *product.product* model ::
58+
It's also possible to add a label printing wizard on any model by
59+
creating a new *ir.actions.act_window* record. For example, to add the
60+
printing wizard on the *product.product* model :
5961

60-
<act_window id="action_wizard_purchase"
61-
name="Print Label"
62-
src_model="product.product"
63-
res_model="wizard.print.record.label"
64-
view_mode="form"
65-
target="new"
66-
key2="client_action_multi"/>
62+
::
63+
64+
<act_window id="action_wizard_purchase"
65+
name="Print Label"
66+
src_model="product.product"
67+
res_model="wizard.print.record.label"
68+
view_mode="form"
69+
target="new"
70+
key2="client_action_multi"/>
6771

6872
Usage
6973
=====
7074

71-
To print a label, you need to call use the label printing method from anywhere (other modules, server actions, etc.).
75+
To print a label, you need to call use the label printing method from
76+
anywhere (other modules, server actions, etc.).
77+
78+
Example : Print the label of a product :
79+
80+
::
7281

73-
Example : Print the label of a product ::
82+
self.env['printing.label.zpl2'].browse(label_id).print_label(
83+
self.env['printing.printer'].browse(printer_id),
84+
self.env['product.product'].browse(product_id))
7485

75-
self.env['printing.label.zpl2'].browse(label_id).print_label(
76-
self.env['printing.printer'].browse(printer_id),
77-
self.env['product.product'].browse(product_id))
86+
You can also use the generic label printing wizard, if added on some
87+
models.
7888

79-
You can also use the generic label printing wizard, if added on some models.
89+
|Try me on Runbot|
8090

81-
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
82-
:alt: Try me on Runbot
91+
.. |Try me on Runbot| image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
8392
:target: https://runbot.odoo-community.org/runbot/144/12.0
8493

8594
Changelog
8695
=========
8796

8897
13.0.1.0.0 (2019-09-30)
89-
~~~~~~~~~~~~~~~~~~~~~~~
98+
-----------------------
9099

91-
* [RELEASE] Port from V12.
92-
* Selection lists do not support integers any longer
93-
* Binary field now returns False when empty instead of none,
94-
change tests to reflect this
95-
* work around an appels vs oranges warning
100+
- [RELEASE] Port from V12.
101+
- Selection lists do not support integers any longer
102+
- Binary field now returns False when empty instead of none, change
103+
tests to reflect this
104+
- work around an appels vs oranges warning
96105

97106
Bug Tracker
98107
===========
99108

100109
Bugs are tracked on `GitHub Issues <https://github.com/OCA/report-print-send/issues>`_.
101110
In case of trouble, please check there if your issue has already been reported.
102111
If you spotted it first, help us to smash it by providing a detailed and welcomed
103-
`feedback <https://github.com/OCA/report-print-send/issues/new?body=module:%20printer_zpl2%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
112+
`feedback <https://github.com/OCA/report-print-send/issues/new?body=module:%20printer_zpl2%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
104113

105114
Do not contact contributors directly about support or help with technical issues.
106115

107116
Credits
108117
=======
109118

110119
Authors
111-
~~~~~~~
120+
-------
112121

113122
* SUBTENO-IT
114123
* FLorent de Labarre
115124
* Apertoso NV
116125

117126
Contributors
118-
~~~~~~~~~~~~
127+
------------
119128

120-
* Sylvain Garancher <[email protected]>
121-
* Florent de Labarre
122-
* Jos De Graeve <[email protected]>
123-
* Rod Schouteden <[email protected]>
124-
* Miquel Raïch <[email protected]>
125-
* Lois Rilo <[email protected]>
126-
* Tran Quoc Duong <[email protected]>
129+
- Sylvain Garancher <[email protected]>
130+
- Florent de Labarre
131+
- Jos De Graeve <[email protected]>
132+
- Rod Schouteden <[email protected]>
133+
- Miquel Raïch <[email protected]>
134+
- Lois Rilo <[email protected]>
135+
- Tran Quoc Duong <[email protected]>
127136

128137
Maintainers
129-
~~~~~~~~~~~
138+
-----------
130139

131140
This module is maintained by the OCA.
132141

@@ -138,6 +147,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
138147
mission is to support the collaborative development of Odoo features and
139148
promote its widespread use.
140149

141-
This module is part of the `OCA/report-print-send <https://github.com/OCA/report-print-send/tree/16.0/printer_zpl2>`_ project on GitHub.
150+
This module is part of the `OCA/report-print-send <https://github.com/OCA/report-print-send/tree/17.0/printer_zpl2>`_ project on GitHub.
142151

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

Diff for: printer_zpl2/models/printing_label_zpl2.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _get_to_data_to_print(
133133
page_count=1,
134134
label_offset_x=0,
135135
label_offset_y=0,
136-
**extra
136+
**extra,
137137
):
138138
to_print = []
139139
for component in self.component_ids:
@@ -200,13 +200,13 @@ def _generate_zpl2_components_data(
200200
page_count=1,
201201
label_offset_x=0,
202202
label_offset_y=0,
203-
**extra
203+
**extra,
204204
):
205205
to_print = self._get_to_data_to_print(
206206
record, page_number, page_count, label_offset_x, label_offset_y, **extra
207207
)
208208

209-
for (component, data, offset_x, offset_y) in to_print:
209+
for component, data, offset_x, offset_y in to_print:
210210
component_offset_x = component.origin_x + offset_x
211211
component_offset_y = component.origin_y + offset_y
212212
if component.component_type == "text":
@@ -307,7 +307,7 @@ def _generate_zpl2_components_data(
307307
else:
308308
if component.component_type == zpl2.BARCODE_QR_CODE:
309309
# Adding Control Arguments to QRCode data Label
310-
data = "{}A,{}".format(component.error_correction, data)
310+
data = f"{component.error_correction}A,{data}"
311311

312312
barcode_arguments = {
313313
field_name: component[field_name]
@@ -356,7 +356,7 @@ def _generate_zpl2_data(self, record, page_count=1, **extra):
356356
record,
357357
page_number=page_number,
358358
page_count=page_count,
359-
**extra
359+
**extra,
360360
)
361361

362362
# Restore printer's configuration and end the label

Diff for: printer_zpl2/models/zpl2.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
BARCODE_QR_CODE = "qr_code"
107107

108108

109-
class Zpl2(object):
109+
class Zpl2:
110110
"""ZPL II management class
111111
Allows to generate data for Zebra printers
112112
"""
@@ -358,11 +358,7 @@ def _field_data_stop(self):
358358

359359
def _field_data(self, data):
360360
"""Add data to the buffer, between start and stop commands"""
361-
command = "{start}{data}{stop}".format(
362-
start=self._field_data_start(),
363-
data=data,
364-
stop=self._field_data_stop(),
365-
)
361+
command = f"{self._field_data_start()}{data}{self._field_data_stop()}"
366362
return command
367363

368364
def font_data(self, right, down, field_format, data):
@@ -500,11 +496,7 @@ def graphic_field(self, right, down, pil_image):
500496
bytes_per_row = rounded_width / 8
501497
total_bytes = bytes_per_row * height
502498
graphic_image_command = (
503-
"^GFA,{total_bytes},{total_bytes},{bytes_per_row},{ascii_data}".format(
504-
total_bytes=total_bytes,
505-
bytes_per_row=bytes_per_row,
506-
ascii_data=ascii_data,
507-
)
499+
f"^GFA,{total_bytes},{total_bytes},{bytes_per_row},{ascii_data}"
508500
)
509501
# Generate the ZPL II command
510502
command = "{origin}{data}{stop}".format(

Diff for: printer_zpl2/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"

Diff for: printer_zpl2/readme/CONFIGURE.rst renamed to printer_zpl2/readme/CONFIGURE.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
To configure this module, you need to:
22

3-
#. Go to *Settings > Printing > Labels > ZPL II*
4-
#. Create new labels
5-
#. Import ZPL2 code
6-
#. Use the Test Mode tab during the creation
3+
1. Go to *Settings \> Printing \> Labels \> ZPL II*
4+
2. Create new labels
5+
3. Import ZPL2 code
6+
4. Use the Test Mode tab during the creation
77

8-
It's also possible to add a label printing wizard on any model by creating a new *ir.actions.act_window* record.
9-
For example, to add the printing wizard on the *product.product* model ::
8+
It's also possible to add a label printing wizard on any model by
9+
creating a new *ir.actions.act_window* record. For example, to add the
10+
printing wizard on the *product.product* model :
1011

1112
<act_window id="action_wizard_purchase"
1213
name="Print Label"

Diff for: printer_zpl2/readme/CONTRIBUTORS.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- Sylvain Garancher \<<[email protected]>\>
2+
- Florent de Labarre
3+
- Jos De Graeve \<<[email protected]>\>
4+
- Rod Schouteden \<<[email protected]>\>
5+
- Miquel Raïch \<<[email protected]>\>
6+
- Lois Rilo \<<[email protected]>\>
7+
- Tran Quoc Duong \<<[email protected]>\>

Diff for: printer_zpl2/readme/CONTRIBUTORS.rst

-7
This file was deleted.

Diff for: printer_zpl2/readme/DESCRIPTION.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This module extends the **Report to printer** (`base_report_to_printer`)
2+
module to add a ZPL II label printing feature.
3+
4+
This module is meant to be used as a base for module development, and
5+
does not provide a GUI on its own. See below for more details.

Diff for: printer_zpl2/readme/DESCRIPTION.rst

-5
This file was deleted.

Diff for: printer_zpl2/readme/HISTORY.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 13.0.1.0.0 (2019-09-30)
2+
3+
- \[RELEASE\] Port from V12.
4+
- Selection lists do not support integers any longer
5+
- Binary field now returns False when empty instead of none, change
6+
tests to reflect this
7+
- work around an appels vs oranges warning

Diff for: printer_zpl2/readme/HISTORY.rst

-8
This file was deleted.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
To print a label, you need to call use the label printing method from anywhere (other modules, server actions, etc.).
1+
To print a label, you need to call use the label printing method from
2+
anywhere (other modules, server actions, etc.).
23

3-
Example : Print the label of a product ::
4+
Example : Print the label of a product :
45

56
self.env['printing.label.zpl2'].browse(label_id).print_label(
67
self.env['printing.printer'].browse(printer_id),
78
self.env['product.product'].browse(product_id))
89

9-
You can also use the generic label printing wizard, if added on some models.
10+
You can also use the generic label printing wizard, if added on some
11+
models.
1012

11-
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
12-
:alt: Try me on Runbot
13-
:target: https://runbot.odoo-community.org/runbot/144/12.0
13+
[![Try me on Runbot](https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas)](https://runbot.odoo-community.org/runbot/144/12.0)

0 commit comments

Comments
 (0)