mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[FIX] printer_zpl2: Adapt code about having the library embedded
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 :
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# generated from manifests external_dependencies
|
||||
pycups
|
||||
zpl2
|
||||
|
||||
Reference in New Issue
Block a user