diff --git a/printer_zpl2/README.rst b/printer_zpl2/README.rst
index cded79e..7ae188d 100644
--- a/printer_zpl2/README.rst
+++ b/printer_zpl2/README.rst
@@ -25,18 +25,18 @@ To configure this module, you need to:
#. Go to *Settings > Printing > Labels > ZPL II*
#. Create new labels
-It's also possible to add a label printing wizard on any model by creating a new *ir.values* record.
+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 :
.. code-block:: xml
-
- Print Product Label
- action
- client_action_multi
- product.product
-
-
+
Usage
=====
@@ -54,7 +54,7 @@ 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/10.0
+ :target: https://runbot.odoo-community.org/runbot/144/11.0
Known issues / Roadmap
======================
@@ -82,6 +82,7 @@ Contributors
------------
* Sylvain Garancher
+* Florent de Labarre
* Jos De Graeve
Maintainer
diff --git a/printer_zpl2/__init__.py b/printer_zpl2/__init__.py
index 6b40cb0..a411d06 100644
--- a/printer_zpl2/__init__.py
+++ b/printer_zpl2/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
diff --git a/printer_zpl2/__manifest__.py b/printer_zpl2/__manifest__.py
index 65fb68d..3fe04b4 100644
--- a/printer_zpl2/__manifest__.py
+++ b/printer_zpl2/__manifest__.py
@@ -1,10 +1,9 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Printer ZPL II',
- 'version': '10.0.1.1.1',
+ 'version': '11.0.1.0.0',
'category': 'Printer',
'author': 'SYLEAM, Apertoso NV, Odoo Community Association (OCA)',
'website': 'http://www.syleam.fr/',
diff --git a/printer_zpl2/models/__init__.py b/printer_zpl2/models/__init__.py
index 048ad6e..4263857 100644
--- a/printer_zpl2/models/__init__.py
+++ b/printer_zpl2/models/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
diff --git a/printer_zpl2/models/printing_label_zpl2.py b/printer_zpl2/models/printing_label_zpl2.py
index 0346118..0cb872d 100644
--- a/printer_zpl2/models/printing_label_zpl2.py
+++ b/printer_zpl2/models/printing_label_zpl2.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -8,8 +7,7 @@ import datetime
import io
import logging
from PIL import Image, ImageOps
-from odoo import api, exceptions, fields, models
-from odoo.tools.translate import _
+from odoo import exceptions, fields, models, _
from odoo.tools.safe_eval import safe_eval
_logger = logging.getLogger(__name__)
@@ -23,8 +21,10 @@ except ImportError:
class PrintingLabelZpl2(models.Model):
_name = 'printing.label.zpl2'
_description = 'ZPL II Label'
+ _order = 'model_id, name, id'
name = fields.Char(required=True, help='Label Name.')
+ active = fields.Boolean(default=True)
description = fields.Char(help='Long description for this label.')
model_id = fields.Many2one(
comodel_name='ir.model', string='Model', required=True,
@@ -47,7 +47,6 @@ class PrintingLabelZpl2(models.Model):
help="Restore printer's saved configuration and end of each label ",
default=True)
- @api.multi
def _generate_zpl2_components_data(
self, label_data, record, page_number=1, page_count=1,
label_offset_x=0, label_offset_y=0, **extra):
@@ -123,7 +122,7 @@ class PrintingLabelZpl2(models.Model):
elif component.component_type == 'graphic':
image = component.graphic_image or data
pil_image = Image.open(io.BytesIO(
- base64.b64decode(image)))
+ base64.b64decode(image))).convert('RGB')
if component.width and component.height:
pil_image = pil_image.resize(
(component.width, component.height))
@@ -188,7 +187,6 @@ class PrintingLabelZpl2(models.Model):
component.origin_y + offset_y,
component.component_type, barcode_arguments, data)
- @api.multi
def _generate_zpl2_data(self, record, page_count=1, **extra):
self.ensure_one()
label_data = zpl2.Zpl2()
@@ -212,7 +210,6 @@ class PrintingLabelZpl2(models.Model):
return label_data.output()
- @api.multi
def print_label(self, printer, record, page_count=1, **extra):
for label in self:
if record._name != label.model_id.model:
@@ -223,6 +220,7 @@ class PrintingLabelZpl2(models.Model):
# Send the label to printer
label_contents = label._generate_zpl2_data(
record, page_count=page_count, **extra)
- printer.print_document(None, label_contents, 'raw')
+ printer.print_document(
+ report=None, content=label_contents, doc_format='raw')
return True
diff --git a/printer_zpl2/models/printing_label_zpl2_component.py b/printer_zpl2/models/printing_label_zpl2_component.py
index 4d4d220..f208712 100644
--- a/printer_zpl2/models/printing_label_zpl2_component.py
+++ b/printer_zpl2/models/printing_label_zpl2_component.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -16,7 +15,7 @@ except ImportError:
class PrintingLabelZpl2Component(models.Model):
_name = 'printing.label.zpl2.component'
_description = 'ZPL II Label Component'
- _order = 'sequence'
+ _order = 'sequence, id'
label_id = fields.Many2one(
comodel_name='printing.label.zpl2', string='Label',
diff --git a/printer_zpl2/tests/__init__.py b/printer_zpl2/tests/__init__.py
index 4483773..c01975e 100644
--- a/printer_zpl2/tests/__init__.py
+++ b/printer_zpl2/tests/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
diff --git a/printer_zpl2/tests/test_printing_label_zpl2.py b/printer_zpl2/tests/test_printing_label_zpl2.py
index f1e95f5..e13bd1e 100644
--- a/printer_zpl2/tests/test_printing_label_zpl2.py
+++ b/printer_zpl2/tests/test_printing_label_zpl2.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@@ -72,7 +71,7 @@ class TestPrintingLabelZpl2(TransactionCase):
def test_empty_label_contents(self):
""" Check contents of an empty label """
label = self.new_label()
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode('utf-8')
self.assertEqual(
contents,
# Label start
@@ -105,7 +104,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'sublabel',
'sublabel_id': sublabel.id,
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode('utf-8')
self.assertEqual(
contents,
# Label start
@@ -150,7 +149,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'repeat_count': 3,
'repeat_offset_y': 15,
})
- contents = label._generate_zpl2_data(label)
+ contents = label._generate_zpl2_data(label).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -210,7 +209,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'repeat_count': 3,
'repeat_offset_y': 15,
})
- contents = label._generate_zpl2_data(label)
+ contents = label._generate_zpl2_data(label).decode('utf-8')
self.assertEqual(
contents,
# Label start
@@ -262,7 +261,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'repeat_count': 3,
'repeat_offset_y': 15,
})
- contents = label._generate_zpl2_data(label)
+ contents = label._generate_zpl2_data(label).decode('utf-8')
self.assertEqual(
contents,
# Label start
@@ -341,7 +340,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'repeat_count': 3,
'repeat_offset_y': 15,
})
- contents = label._generate_zpl2_data(label)
+ contents = label._generate_zpl2_data(label).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -403,9 +402,9 @@ class TestPrintingLabelZpl2(TransactionCase):
data = 'Some text'
self.new_component({
'label_id': label.id,
- 'data': '"' + data + '"',
+ 'data': '"%s"' % data,
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -438,7 +437,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'data': '"' + data + '"',
'reverse_print': True,
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -473,7 +472,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'data': '"' + data + '"',
'in_block': True,
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -506,7 +505,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'label_id': label.id,
'component_type': 'rectangle',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -535,7 +534,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'label_id': label.id,
'component_type': 'circle',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -566,7 +565,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'code_11',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -601,7 +600,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'interleaved_2_of_5',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -636,7 +635,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'code_39',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -671,7 +670,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'code_49',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -707,7 +706,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'data': '"' + data + '"',
'interpretation_line': True,
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -746,7 +745,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'interpretation_line': True,
'interpretation_line_above': True,
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -781,7 +780,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'pdf417',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -816,7 +815,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'ean-8',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -851,7 +850,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'upc-e',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -886,7 +885,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'code_128',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -921,7 +920,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'ean-13',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
@@ -956,7 +955,7 @@ class TestPrintingLabelZpl2(TransactionCase):
'component_type': 'qr_code',
'data': '"' + data + '"',
})
- contents = label._generate_zpl2_data(self.printer)
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
self.assertEqual(
contents,
# Label start
diff --git a/printer_zpl2/tests/test_wizard_print_record_label.py b/printer_zpl2/tests/test_wizard_print_record_label.py
index 5333294..a2aa6d6 100644
--- a/printer_zpl2/tests/test_wizard_print_record_label.py
+++ b/printer_zpl2/tests/test_wizard_print_record_label.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
diff --git a/printer_zpl2/views/printing_label_zpl2.xml b/printer_zpl2/views/printing_label_zpl2.xml
index 6106e2e..a78b255 100644
--- a/printer_zpl2/views/printing_label_zpl2.xml
+++ b/printer_zpl2/views/printing_label_zpl2.xml
@@ -5,7 +5,6 @@
-->
- printing.label.zpl2.tree
printing.label.zpl2
@@ -15,115 +14,125 @@
- printing.label.zpl2.form
printing.label.zpl2
- printing.label.zpl2.search
printing.label.zpl2
+
diff --git a/printer_zpl2/wizard/__init__.py b/printer_zpl2/wizard/__init__.py
index 5c68984..c9a79f0 100644
--- a/printer_zpl2/wizard/__init__.py
+++ b/printer_zpl2/wizard/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
diff --git a/printer_zpl2/wizard/print_record_label.py b/printer_zpl2/wizard/print_record_label.py
index bf39b0f..1944960 100644
--- a/printer_zpl2/wizard/print_record_label.py
+++ b/printer_zpl2/wizard/print_record_label.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM ()
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -38,7 +37,6 @@ class PrintRecordLabel(models.TransientModel):
return values
- @api.multi
def print_label(self):
""" Prints a label per selected record """
record_model = self.env.context['active_model']
diff --git a/printer_zpl2/wizard/print_record_label.xml b/printer_zpl2/wizard/print_record_label.xml
index ed64c90..4f19936 100644
--- a/printer_zpl2/wizard/print_record_label.xml
+++ b/printer_zpl2/wizard/print_record_label.xml
@@ -13,7 +13,10 @@
-
+