diff --git a/printer_zpl2/__manifest__.py b/printer_zpl2/__manifest__.py index 7d3d916..4ed0f44 100644 --- a/printer_zpl2/__manifest__.py +++ b/printer_zpl2/__manifest__.py @@ -10,7 +10,6 @@ "Apertoso NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/report-print-send", "license": "AGPL-3", - "external_dependencies": {"python": ["zpl2"]}, "depends": ["base_report_to_printer"], "data": [ "security/ir.model.access.csv", diff --git a/printer_zpl2/models/printing_label_zpl2.py b/printer_zpl2/models/printing_label_zpl2.py index dfd860a..e9e5e9b 100644 --- a/printer_zpl2/models/printing_label_zpl2.py +++ b/printer_zpl2/models/printing_label_zpl2.py @@ -14,12 +14,9 @@ from odoo import _, api, exceptions, fields, models from odoo.exceptions import ValidationError from odoo.tools.safe_eval import safe_eval, wrap_module -_logger = logging.getLogger(__name__) +from . import zpl2 -try: - import zpl2 -except ImportError: - _logger.debug("Cannot `import zpl2`.") +_logger = logging.getLogger(__name__) class PrintingLabelZpl2(models.Model): diff --git a/printer_zpl2/models/printing_label_zpl2_component.py b/printer_zpl2/models/printing_label_zpl2_component.py index 9342ec5..eccd2ef 100644 --- a/printer_zpl2/models/printing_label_zpl2_component.py +++ b/printer_zpl2/models/printing_label_zpl2_component.py @@ -5,12 +5,10 @@ import logging from odoo import api, fields, models +from . import zpl2 + _logger = logging.getLogger(__name__) -try: - import zpl2 -except ImportError: - _logger.debug("Cannot `import zpl2`.") DEFAULT_PYTHON_CODE = """# Python One-Liners # - object: %s record on which the action is triggered; may be void diff --git a/printer_zpl2/models/zpl2.py b/printer_zpl2/models/zpl2.py index 00db219..d9600b6 100644 --- a/printer_zpl2/models/zpl2.py +++ b/printer_zpl2/models/zpl2.py @@ -8,15 +8,7 @@ import binascii import math -try: - from PIL import ImageOps -except: - ImageOps = None - -try: - strcast = unicode -except: - strcast = str +from PIL import ImageOps # Constants for the printer configuration management CONF_RELOAD_FACTORY = "F" @@ -136,7 +128,7 @@ class Zpl2(object): def _write_command(self, data): """Adds a complete command to buffer""" - self._buffer.append(strcast(data).encode(self.encoding)) + self._buffer.append(str(data).encode(self.encoding)) def _generate_arguments(self, arguments, kwargs): """Generate a zebra arguments from an argument names list and a dict of @@ -492,12 +484,6 @@ class Zpl2(object): def graphic_field(self, right, down, pil_image): """Encode a PIL image into an ASCII string suitable for ZPL printers""" - if ImageOps is None: - # Importing ImageOps from PIL didn't work - raise Exception( - "You must install Pillow to be able to use the graphic" - " fields feature" - ) width, height = pil_image.size rounded_width = int(math.ceil(width / 8.0) * 8) # Transform the image : diff --git a/printer_zpl2/tests/test_printing_label_zpl2.py b/printer_zpl2/tests/test_printing_label_zpl2.py index f78322d..41f1470 100644 --- a/printer_zpl2/tests/test_printing_label_zpl2.py +++ b/printer_zpl2/tests/test_printing_label_zpl2.py @@ -1,19 +1,12 @@ # Copyright 2016 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -import logging - import mock from odoo import exceptions from odoo.tests.common import TransactionCase -_logger = logging.getLogger(__name__) - -try: - import zpl2 -except ImportError: - _logger.debug("Cannot `import zpl2`.") +from ..models import zpl2 model = "odoo.addons.base_report_to_printer.models.printing_server" diff --git a/printer_zpl2/wizard/wizard_import_zpl2.py b/printer_zpl2/wizard/wizard_import_zpl2.py index 6493564..f6adc79 100644 --- a/printer_zpl2/wizard/wizard_import_zpl2.py +++ b/printer_zpl2/wizard/wizard_import_zpl2.py @@ -11,12 +11,9 @@ from PIL import Image, ImageOps from odoo import _, fields, models -_logger = logging.getLogger(__name__) +from ..models import zpl2 -try: - import zpl2 -except ImportError: - _logger.debug("Cannot `import zpl2`.") +_logger = logging.getLogger(__name__) def _compute_arg(data, arg): diff --git a/requirements.txt b/requirements.txt index f1fc07a..3426931 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ # generated from manifests external_dependencies pycups -zpl2