Skip to content

Commit

Permalink
[IMP] printer_zpl2: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fmdl authored and OCA-git-bot committed Dec 4, 2024
1 parent fb34e0e commit 336b3bc
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 159 deletions.
101 changes: 55 additions & 46 deletions printer_zpl2/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@ Printer ZPL II
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github
:target: https://github.com/OCA/report-print-send/tree/16.0/printer_zpl2
:target: https://github.com/OCA/report-print-send/tree/17.0/printer_zpl2
:alt: OCA/report-print-send
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/report-print-send-16-0/report-print-send-16-0-printer_zpl2
:target: https://translation.odoo-community.org/projects/report-print-send-17-0/report-print-send-17-0-printer_zpl2
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the **Report to printer** (``base_report_to_printer``)
module to add a ZPL II label printing feature.
This module extends the **Report to printer**
(``base_report_to_printer``) module to add a ZPL II label printing
feature.

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

**Table of contents**

Expand All @@ -49,84 +50,92 @@ Configuration

To configure this module, you need to:

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

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

<act_window id="action_wizard_purchase"
name="Print Label"
src_model="product.product"
res_model="wizard.print.record.label"
view_mode="form"
target="new"
key2="client_action_multi"/>
::

<act_window id="action_wizard_purchase"
name="Print Label"
src_model="product.product"
res_model="wizard.print.record.label"
view_mode="form"
target="new"
key2="client_action_multi"/>

Usage
=====

To print a label, you need to call use the label printing method from anywhere (other modules, server actions, etc.).
To print a label, you need to call use the label printing method from
anywhere (other modules, server actions, etc.).

Example : Print the label of a product :

::

Example : Print the label of a product ::
self.env['printing.label.zpl2'].browse(label_id).print_label(
self.env['printing.printer'].browse(printer_id),
self.env['product.product'].browse(product_id))

self.env['printing.label.zpl2'].browse(label_id).print_label(
self.env['printing.printer'].browse(printer_id),
self.env['product.product'].browse(product_id))
You can also use the generic label printing wizard, if added on some
models.

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

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

Changelog
=========

13.0.1.0.0 (2019-09-30)
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------

* [RELEASE] Port from V12.
* Selection lists do not support integers any longer
* Binary field now returns False when empty instead of none,
change tests to reflect this
* work around an appels vs oranges warning
- [RELEASE] Port from V12.
- Selection lists do not support integers any longer
- Binary field now returns False when empty instead of none, change
tests to reflect this
- work around an appels vs oranges warning

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/report-print-send/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.
`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**>`_.

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

Credits
=======

Authors
~~~~~~~
-------

* SUBTENO-IT
* FLorent de Labarre
* Apertoso NV

Contributors
~~~~~~~~~~~~
------------

* Sylvain Garancher <[email protected]>
* Florent de Labarre
* Jos De Graeve <[email protected]>
* Rod Schouteden <[email protected]>
* Miquel Raïch <[email protected]>
* Lois Rilo <[email protected]>
* Tran Quoc Duong <[email protected]>
- Sylvain Garancher <[email protected]>
- Florent de Labarre
- Jos De Graeve <[email protected]>
- Rod Schouteden <[email protected]>
- Miquel Raïch <[email protected]>
- Lois Rilo <[email protected]>
- Tran Quoc Duong <[email protected]>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

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

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.
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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
10 changes: 5 additions & 5 deletions printer_zpl2/models/printing_label_zpl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _get_to_data_to_print(
page_count=1,
label_offset_x=0,
label_offset_y=0,
**extra
**extra,
):
to_print = []
for component in self.component_ids:
Expand Down Expand Up @@ -200,13 +200,13 @@ def _generate_zpl2_components_data(
page_count=1,
label_offset_x=0,
label_offset_y=0,
**extra
**extra,
):
to_print = self._get_to_data_to_print(
record, page_number, page_count, label_offset_x, label_offset_y, **extra
)

for (component, data, offset_x, offset_y) in to_print:
for component, data, offset_x, offset_y in to_print:
component_offset_x = component.origin_x + offset_x
component_offset_y = component.origin_y + offset_y
if component.component_type == "text":
Expand Down Expand Up @@ -307,7 +307,7 @@ def _generate_zpl2_components_data(
else:
if component.component_type == zpl2.BARCODE_QR_CODE:
# Adding Control Arguments to QRCode data Label
data = "{}A,{}".format(component.error_correction, data)
data = f"{component.error_correction}A,{data}"

barcode_arguments = {
field_name: component[field_name]
Expand Down Expand Up @@ -356,7 +356,7 @@ def _generate_zpl2_data(self, record, page_count=1, **extra):
record,
page_number=page_number,
page_count=page_count,
**extra
**extra,
)

# Restore printer's configuration and end the label
Expand Down
14 changes: 3 additions & 11 deletions printer_zpl2/models/zpl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
BARCODE_QR_CODE = "qr_code"


class Zpl2(object):
class Zpl2:
"""ZPL II management class
Allows to generate data for Zebra printers
"""
Expand Down Expand Up @@ -358,11 +358,7 @@ def _field_data_stop(self):

def _field_data(self, data):
"""Add data to the buffer, between start and stop commands"""
command = "{start}{data}{stop}".format(
start=self._field_data_start(),
data=data,
stop=self._field_data_stop(),
)
command = f"{self._field_data_start()}{data}{self._field_data_stop()}"
return command

def font_data(self, right, down, field_format, data):
Expand Down Expand Up @@ -500,11 +496,7 @@ def graphic_field(self, right, down, pil_image):
bytes_per_row = rounded_width / 8
total_bytes = bytes_per_row * height
graphic_image_command = (
"^GFA,{total_bytes},{total_bytes},{bytes_per_row},{ascii_data}".format(
total_bytes=total_bytes,
bytes_per_row=bytes_per_row,
ascii_data=ascii_data,
)
f"^GFA,{total_bytes},{total_bytes},{bytes_per_row},{ascii_data}"
)
# Generate the ZPL II command
command = "{origin}{data}{stop}".format(
Expand Down
3 changes: 3 additions & 0 deletions printer_zpl2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
To configure this module, you need to:

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

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

<act_window id="action_wizard_purchase"
name="Print Label"
Expand Down
7 changes: 7 additions & 0 deletions printer_zpl2/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Sylvain Garancher \<<[email protected]>\>
- Florent de Labarre
- Jos De Graeve \<<[email protected]>\>
- Rod Schouteden \<<[email protected]>\>
- Miquel Raïch \<<[email protected]>\>
- Lois Rilo \<<[email protected]>\>
- Tran Quoc Duong \<<[email protected]>\>
7 changes: 0 additions & 7 deletions printer_zpl2/readme/CONTRIBUTORS.rst

This file was deleted.

5 changes: 5 additions & 0 deletions printer_zpl2/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module extends the **Report to printer** (`base_report_to_printer`)
module to add a ZPL II label printing feature.

This module is meant to be used as a base for module development, and
does not provide a GUI on its own. See below for more details.
5 changes: 0 additions & 5 deletions printer_zpl2/readme/DESCRIPTION.rst

This file was deleted.

7 changes: 7 additions & 0 deletions printer_zpl2/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 13.0.1.0.0 (2019-09-30)

- \[RELEASE\] Port from V12.
- Selection lists do not support integers any longer
- Binary field now returns False when empty instead of none, change
tests to reflect this
- work around an appels vs oranges warning
8 changes: 0 additions & 8 deletions printer_zpl2/readme/HISTORY.rst

This file was deleted.

File renamed without changes.
12 changes: 6 additions & 6 deletions printer_zpl2/readme/USAGE.rst → printer_zpl2/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
To print a label, you need to call use the label printing method from anywhere (other modules, server actions, etc.).
To print a label, you need to call use the label printing method from
anywhere (other modules, server actions, etc.).

Example : Print the label of a product ::
Example : Print the label of a product :

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

You can also use the generic label printing wizard, if added on some models.
You can also use the generic label printing wizard, if added on some
models.

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

0 comments on commit 336b3bc

Please sign in to comment.