mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] Add diagonal lines management
This commit is contained in:
committed by
Lois Rilo
parent
1024ddfa42
commit
59be9bc048
@@ -123,6 +123,16 @@ class PrintingLabelZpl2(models.Model):
|
||||
zpl2.ARG_COLOR: component.color,
|
||||
zpl2.ARG_ROUNDING: component.rounding,
|
||||
})
|
||||
elif component.component_type == 'diagonal':
|
||||
label_data.graphic_diagonal_line(
|
||||
component_offset_x, component_offset_y, {
|
||||
zpl2.ARG_WIDTH: component.width,
|
||||
zpl2.ARG_HEIGHT: component.height,
|
||||
zpl2.ARG_THICKNESS: component.thickness,
|
||||
zpl2.ARG_COLOR: component.color,
|
||||
zpl2.ARG_DIAGONAL_ORIENTATION:
|
||||
component.diagonal_orientation,
|
||||
})
|
||||
elif component.component_type == 'graphic':
|
||||
image = component.graphic_image or data
|
||||
pil_image = Image.open(io.BytesIO(
|
||||
|
||||
@@ -42,6 +42,7 @@ class PrintingLabelZpl2Component(models.Model):
|
||||
selection=[
|
||||
('text', 'Text'),
|
||||
('rectangle', 'Rectangle / Line'),
|
||||
('diagonal', 'Diagonal Line'),
|
||||
('circle', 'Circle'),
|
||||
('graphic', 'Graphic'),
|
||||
(zpl2.BARCODE_CODE_11, 'Code 11'),
|
||||
@@ -85,6 +86,12 @@ class PrintingLabelZpl2Component(models.Model):
|
||||
(zpl2.ORIENTATION_BOTTOM_UP, 'Read from Bottom up'),
|
||||
], required=True, default=zpl2.ORIENTATION_NORMAL,
|
||||
help='Orientation of the barcode.')
|
||||
diagonal_orientation = fields.Selection(
|
||||
selection=[
|
||||
(zpl2.DIAGONAL_ORIENTATION_LEFT, 'Left (\\)'),
|
||||
(zpl2.DIAGONAL_ORIENTATION_RIGHT, 'Right (/)'),
|
||||
], default=zpl2.DIAGONAL_ORIENTATION_LEFT,
|
||||
help='Orientation of the diagonal line.')
|
||||
check_digits = fields.Boolean(
|
||||
help='Check if you want to compute and print the check digit.')
|
||||
height = fields.Integer(
|
||||
|
||||
@@ -527,6 +527,35 @@ class TestPrintingLabelZpl2(TransactionCase):
|
||||
# Label end
|
||||
'^XZ')
|
||||
|
||||
def test_diagonal_line_label_contents(self):
|
||||
""" Check contents of a diagonal line label """
|
||||
label = self.new_label()
|
||||
self.new_component({
|
||||
'label_id': label.id,
|
||||
'component_type': 'diagonal',
|
||||
})
|
||||
contents = label._generate_zpl2_data(self.printer).decode("utf-8")
|
||||
self.assertEqual(
|
||||
contents,
|
||||
# Label start
|
||||
'^XA\n'
|
||||
# Print width
|
||||
'^PW480\n'
|
||||
# UTF-8 encoding
|
||||
'^CI28\n'
|
||||
# Label position
|
||||
'^LH10,10\n'
|
||||
# Component position
|
||||
'^FO10,10'
|
||||
# Component format
|
||||
'^GD3,3,1,B,L'
|
||||
# Component end
|
||||
'^FS\n'
|
||||
# Recall last saved parameters
|
||||
'^JUR\n'
|
||||
# Label end
|
||||
'^XZ')
|
||||
|
||||
def test_circle_label_contents(self):
|
||||
""" Check contents of a circle label """
|
||||
label = self.new_label()
|
||||
|
||||
@@ -64,24 +64,25 @@
|
||||
<field name="sublabel_id" attrs="{'invisible': [('component_type', '!=', 'sublabel')]}"/>
|
||||
</group>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('component_type', 'in', ('rectangle', 'circle'))]}" string="Data">
|
||||
<group attrs="{'invisible': [('component_type', 'in', ('rectangle', 'diagonal', 'circle'))]}" string="Data">
|
||||
<field name="data" widget="ace" options="{'mode': 'python'}" nolabel="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Format" attrs="{'invisible': [('component_type', 'in', ('sublabel', 'qr_code', 'zpl2_raw'))]}">
|
||||
<group>
|
||||
<field name="height"/>
|
||||
<field name="width" attrs="{'invisible': [('component_type', 'not in', ('text', 'rectangle', 'circle', 'graphic'))]}"/>
|
||||
<field name="width" attrs="{'invisible': [('component_type', 'not in', ('text', 'rectangle', 'diagonal', 'circle', 'graphic'))]}"/>
|
||||
<field name="reverse_print"/>
|
||||
<field name="orientation" attrs="{'invisible': [('component_type', 'in', ('rectangle', 'circle'))]}"/>
|
||||
<field name="orientation" attrs="{'invisible': [('component_type', 'in', ('rectangle', 'diagonal', 'circle'))]}"/>
|
||||
<field name="font" attrs="{'invisible': [('component_type', '!=', 'text')]}"/>
|
||||
<field name="in_block" attrs="{'invisible': [('component_type', '!=', 'text')]}"/>
|
||||
<field name="thickness" attrs="{'invisible': [('component_type', 'not in', ('rectangle', 'circle'))]}"/>
|
||||
<field name="color" attrs="{'invisible': [('component_type', 'not in', ('rectangle', 'circle'))]}"/>
|
||||
<field name="thickness" attrs="{'invisible': [('component_type', 'not in', ('rectangle', 'diagonal', 'circle'))]}"/>
|
||||
<field name="color" attrs="{'invisible': [('component_type', 'not in', ('rectangle', 'diagonal', 'circle'))]}"/>
|
||||
<field name="diagonal_orientation" attrs="{'invisible': [('component_type', '!=', 'diagonal')], 'required': [('component_type', '=', 'diagonal')]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<!-- Barcode specific arguments -->
|
||||
<page string="Barcode Format" attrs="{'invisible': [('component_type', 'in', ('text', 'rectangle', 'circle', 'sublabel', 'graphic', 'qr_code', 'zpl2_raw'))]}">
|
||||
<page string="Barcode Format" attrs="{'invisible': [('component_type', 'in', ('text', 'rectangle', 'diagonal', 'circle', 'sublabel', 'graphic', 'qr_code', 'zpl2_raw'))]}">
|
||||
<group>
|
||||
<field name="check_digits"/>
|
||||
<field name="interpretation_line"/>
|
||||
|
||||
Reference in New Issue
Block a user