diff --git a/printer_zpl2/models/printing_label_zpl2.py b/printer_zpl2/models/printing_label_zpl2.py
index 0cb872d..dcbf3a4 100644
--- a/printer_zpl2/models/printing_label_zpl2.py
+++ b/printer_zpl2/models/printing_label_zpl2.py
@@ -110,6 +110,8 @@ class PrintingLabelZpl2(models.Model):
label_data.font_data(
component_offset_x, component_offset_y,
barcode_arguments, data)
+ elif component.component_type == 'zpl2_raw':
+ label_data._write_command(data)
elif component.component_type == 'rectangle':
label_data.graphic_box(
component_offset_x, component_offset_y, {
diff --git a/printer_zpl2/models/printing_label_zpl2_component.py b/printer_zpl2/models/printing_label_zpl2_component.py
index f208712..903169e 100644
--- a/printer_zpl2/models/printing_label_zpl2_component.py
+++ b/printer_zpl2/models/printing_label_zpl2_component.py
@@ -11,6 +11,16 @@ try:
except ImportError:
_logger.debug('Cannot `import zpl2`.')
+DEFAULT_PYTHON_CODE = """# Python One-Liners
+# - object: record on which the action is triggered; may be be void
+# - page_number: Current Page
+# - page_count: Total Page
+# - time, datetime: Python libraries
+# Exemple : object.name
+
+""
+"""
+
class PrintingLabelZpl2Component(models.Model):
_name = 'printing.label.zpl2.component'
@@ -45,6 +55,7 @@ class PrintingLabelZpl2Component(models.Model):
(zpl2.BARCODE_EAN_13, 'EAN-13'),
(zpl2.BARCODE_QR_CODE, 'QR Code'),
('sublabel', 'Sublabel'),
+ ('zpl2_raw', 'ZPL2'),
], string='Type', required=True, default='text', oldname='type',
help='Type of content, simple text or barcode.')
font = fields.Selection(
@@ -115,8 +126,8 @@ class PrintingLabelZpl2Component(models.Model):
], required=True, default=zpl2.ERROR_CORRECTION_HIGH,
help='Error correction for some barcode types like QR Code.')
mask_value = fields.Integer(default=7, help='Mask Value, from 0 to 7.')
- data = fields.Char(
- size=256, default='""', required=True,
+ data = fields.Text(
+ default=DEFAULT_PYTHON_CODE, required=True,
help='Data to print on this component. Resource values can be '
'inserted with %(object.field_name)s.')
sublabel_id = fields.Many2one(
diff --git a/printer_zpl2/tests/test_printing_label_zpl2.py b/printer_zpl2/tests/test_printing_label_zpl2.py
index e13bd1e..ec610fe 100644
--- a/printer_zpl2/tests/test_printing_label_zpl2.py
+++ b/printer_zpl2/tests/test_printing_label_zpl2.py
@@ -1068,3 +1068,22 @@ class TestPrintingLabelZpl2(TransactionCase):
"^JUR\n"
"^XZ")
+ def test_zpl2_raw_contents_blank(self):
+ """ Check contents of a image label """
+ label = self.new_label()
+ data = '^FO50,50^GB100,100,100^FS'
+ self.new_component({
+ 'label_id': label.id,
+ 'component_type': 'zpl2_raw',
+ 'data': '"' + data + '"',
+ })
+ contents = label._generate_zpl2_data(self.printer).decode("utf-8")
+ self.assertEqual(
+ contents,
+ '^XA\n'
+ '^PW480\n'
+ '^CI28\n'
+ '^LH10,10\n'
+ '^FO50,50^GB100,100,100^FS\n'
+ '^JUR\n'
+ '^XZ')
diff --git a/printer_zpl2/views/printing_label_zpl2.xml b/printer_zpl2/views/printing_label_zpl2.xml
index a78b255..aad0e9f 100644
--- a/printer_zpl2/views/printing_label_zpl2.xml
+++ b/printer_zpl2/views/printing_label_zpl2.xml
@@ -50,20 +50,22 @@
-
+
-
+
-
+
+
+
-
+
@@ -76,7 +78,7 @@
-
+