~opencrea/+junk/aprobio

« back to all changes in this revision

Viewing changes to printer_zpl2/models/printing_label_zpl2_component.py

  • Committer: joannes
  • Date: 2017-05-17 09:40:42 UTC
  • Revision ID: joannes@debian-20170517094042-47q3j6on72w2h1il
community module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
 
3
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
 
4
 
 
5
import logging
 
6
from odoo import fields, models
 
7
 
 
8
_logger = logging.getLogger(__name__)
 
9
 
 
10
try:
 
11
    import zpl2
 
12
except ImportError:
 
13
    _logger.debug('Cannot `import zpl2`.')
 
14
 
 
15
 
 
16
class PrintingLabelZpl2Component(models.Model):
 
17
    _name = 'printing.label.zpl2.component'
 
18
    _description = 'ZPL II Label Component'
 
19
    _order = 'sequence'
 
20
 
 
21
    label_id = fields.Many2one(
 
22
        comodel_name='printing.label.zpl2', string='Label',
 
23
        required=True, ondelete='cascade', help='Label using this component.')
 
24
    sequence = fields.Integer(help='Order used to print the elements.')
 
25
    name = fields.Char(required=True, help='Name of the component.')
 
26
    origin_x = fields.Integer(
 
27
        required=True, default=10,
 
28
        help='Origin point of the component in the label, X coordinate.')
 
29
    origin_y = fields.Integer(
 
30
        required=True, default=10,
 
31
        help='Origin point of the component in the label, Y coordinate.')
 
32
    component_type = fields.Selection(
 
33
        selection=[
 
34
            ('text', 'Text'),
 
35
            ('rectangle', 'Rectangle / Line'),
 
36
            ('circle', 'Circle'),
 
37
            (zpl2.BARCODE_CODE_11, 'Code 11'),
 
38
            (zpl2.BARCODE_INTERLEAVED_2_OF_5, 'Interleaved 2 of 5'),
 
39
            (zpl2.BARCODE_CODE_39, 'Code 39'),
 
40
            (zpl2.BARCODE_CODE_49, 'Code 49'),
 
41
            (zpl2.BARCODE_PDF417, 'PDF417'),
 
42
            (zpl2.BARCODE_EAN_8, 'EAN-8'),
 
43
            (zpl2.BARCODE_UPC_E, 'UPC-E'),
 
44
            (zpl2.BARCODE_CODE_128, 'Code 128'),
 
45
            (zpl2.BARCODE_EAN_13, 'EAN-13'),
 
46
            ('sublabel', 'Sublabel'),
 
47
        ], string='Type', required=True, default='text', oldname='type',
 
48
        help='Type of content, simple text or barcode.')
 
49
    font = fields.Selection(
 
50
        selection=[
 
51
            (zpl2.FONT_DEFAULT, 'Default'),
 
52
            (zpl2.FONT_9X5, '9x5'),
 
53
            (zpl2.FONT_11X7, '11x7'),
 
54
            (zpl2.FONT_18X10, '18x10'),
 
55
            (zpl2.FONT_28X15, '28x15'),
 
56
            (zpl2.FONT_26X13, '26x13'),
 
57
            (zpl2.FONT_60X40, '60x40'),
 
58
            (zpl2.FONT_21X13, '21x13'),
 
59
        ], required=True, default=zpl2.FONT_DEFAULT,
 
60
        help='Font to use, for text only.')
 
61
    thickness = fields.Integer(help='Thickness of the line to draw.')
 
62
    color = fields.Selection(
 
63
        selection=[
 
64
            (zpl2.COLOR_BLACK, 'Black'),
 
65
            (zpl2.COLOR_WHITE, 'White'),
 
66
        ], default=zpl2.COLOR_BLACK,
 
67
        help='Color of the line to draw.')
 
68
    orientation = fields.Selection(
 
69
        selection=[
 
70
            (zpl2.ORIENTATION_NORMAL, 'Normal'),
 
71
            (zpl2.ORIENTATION_ROTATED, 'Rotated'),
 
72
            (zpl2.ORIENTATION_INVERTED, 'Inverted'),
 
73
            (zpl2.ORIENTATION_BOTTOM_UP, 'Read from Bottom up'),
 
74
        ], required=True, default=zpl2.ORIENTATION_NORMAL,
 
75
        help='Orientation of the barcode.')
 
76
    check_digits = fields.Boolean(
 
77
        help='Check if you want to compute and print the check digit.')
 
78
    height = fields.Integer(
 
79
        help='Height of the printed component. For a text component, height '
 
80
        'of a single character.')
 
81
    width = fields.Integer(
 
82
        help='Width of the printed component. For a text component, width of '
 
83
        'a single character.')
 
84
    rounding = fields.Integer(
 
85
        help='Rounding of the printed rectangle corners.')
 
86
    interpretation_line = fields.Boolean(
 
87
        help='Check if you want the interpretation line to be printed.')
 
88
    interpretation_line_above = fields.Boolean(
 
89
        help='Check if you want the interpretation line to be printed above '
 
90
        'the barcode.')
 
91
    module_width = fields.Integer(
 
92
        default=2, help='Module width for the barcode.')
 
93
    bar_width_ratio = fields.Float(
 
94
        default=3.0, help='Ratio between wide bar and narrow bar.')
 
95
    security_level = fields.Integer(help='Security level for error detection.')
 
96
    columns_count = fields.Integer(help='Number of data columns to encode.')
 
97
    rows_count = fields.Integer(help='Number of rows to encode.')
 
98
    truncate = fields.Boolean(
 
99
        help='Check if you want to truncate the barcode.')
 
100
    data = fields.Char(
 
101
        size=256, default='""', required=True,
 
102
        help='Data to print on this component. Resource values can be '
 
103
        'inserted with %(object.field_name)s.')
 
104
    sublabel_id = fields.Many2one(
 
105
        comodel_name='printing.label.zpl2', string='Sublabel',
 
106
        help='Another label to include into this one as a component. '
 
107
        'This allows to define reusable labels parts.')
 
108
    repeat = fields.Boolean(
 
109
        string='Repeatable',
 
110
        help='Check this box to repeat this component on the label.')
 
111
    repeat_offset = fields.Integer(
 
112
        default=0,
 
113
        help='Number of elements to skip when reading a list of elements.')
 
114
    repeat_count = fields.Integer(
 
115
        default=1,
 
116
        help='Maximum count of repeats of the component.')
 
117
    repeat_offset_x = fields.Integer(
 
118
        help='X coordinate offset between each occurence of this component on '
 
119
        'the label.')
 
120
    repeat_offset_y = fields.Integer(
 
121
        help='Y coordinate offset between each occurence of this component on '
 
122
        'the label.')
 
123
    reverse_print = fields.Boolean(
 
124
        help='If checked, the data will be printed in the inverse color of '
 
125
        'the background.')
 
126
    in_block = fields.Boolean(
 
127
        help='If checked, the data will be restrected in a '
 
128
        'defined block on the label.')
 
129
    block_width = fields.Integer(help='Width of the block.')
 
130
    block_lines = fields.Integer(
 
131
        default=1, help='Maximum number of lines to print in the block.')
 
132
    block_spaces = fields.Integer(
 
133
        help='Number of spaces added between lines in the block.')
 
134
    block_justify = fields.Selection(
 
135
        selection=[
 
136
            (zpl2.JUSTIFY_LEFT, 'Left'),
 
137
            (zpl2.JUSTIFY_CENTER, 'Center'),
 
138
            (zpl2.JUSTIFY_JUSTIFIED, 'Justified'),
 
139
            (zpl2.JUSTIFY_RIGHT, 'Right'),
 
140
        ], string='Justify', required=True, default='L',
 
141
        help='Choose how the text will be justified in the block.')
 
142
    block_left_margin = fields.Integer(
 
143
        string='Left Margin',
 
144
        help='Left margin for the second and other lines in the block.')