1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
5
# Jordi Esteve <jesteve@zikzakmedia.com>
7
# WARNING: This program as such is intended to be used by professional
8
# programmers who take the whole responsability of assessing all potential
9
# consequences resulting from its eventual inadequacies and bugs
10
# End users who are looking for a ready-to-use solution with commercial
11
# garantees and support are strongly adviced to contract a Free Software
14
# This program is Free Software; you can redistribute it and/or
15
# modify it under the terms of the GNU General Public License
16
# as published by the Free Software Foundation; either version 2
17
# of the License, or (at your option) any later version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
##############################################################################
30
from osv import osv, fields
33
class report_pagesize(osv.osv):
34
_name = 'report.pagesize'
36
'name': fields.char('Name', size=20, required=True),
37
'width': fields.char('Width', size=20, required=True, help="Numeric width of the page ended with the unit (cm or in). For example, A4 is 21cm and letter is 8.5in"),
38
'height': fields.char('Height', size=20, required=True, help="Numeric height of the page ended with the unit (cm or in). For example, A4 is 29.7cm and letter is 11in"),
42
def _check_unit(self, cr, uid, ids):
43
for page in self.browse(cr, uid, ids):
44
if page.width[-2:] not in ['cm', 'in']:
46
if page.height[-2:] not in ['cm', 'in']:
51
(_check_unit, 'Error! The page sizes do not have the unit (cm or in) at the end.', [])
57
class report_label_manufacturer(osv.osv):
58
_name = 'report.label.manufacturer'
60
'name': fields.char('Name', size=50, required=True),
64
report_label_manufacturer()
67
class report_label(osv.osv):
68
def name_get(self, cr, uid, ids, context=None):
72
for r in self.browse(cr, uid, ids):
73
name = str(r.manufacturer_id.name or '') + ". " + str(r.name)
74
res.append((r.id, name))
77
_name = 'report.label'
79
'name': fields.char('Name', size=200, required=True),
80
'manufacturer_id': fields.many2one('report.label.manufacturer', 'Manufacturer'),
81
'description': fields.text('Description'),
82
'pagesize_id': fields.many2one('report.pagesize', 'Page Size', required=True),
83
'landscape': fields.boolean('Landscape', help="No check -> Portrait. Check -> Landscape"),
84
'rows': fields.integer('Number of Rows', size=2, required=True),
85
'cols': fields.integer('Number of Columns', size=2, required=True),
86
'label_width': fields.char('Label Width', size=20, required=True, help="Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
87
'label_height': fields.char('Label Height', size=20, required=True, help="Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
88
'width_incr': fields.char('Width Increment', size=20, required=True, help="Width between start positions of 2 labels. Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
89
'height_incr': fields.char('Height Increment', size=20, required=True, help="Height between start positions of 2 labels. Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
90
'margin_top': fields.char('Top Margin', size=20, required=True, help="Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
91
'margin_left': fields.char('Left Margin', size=20, required=True, help="Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
92
#'margin_bottom': fields.char('Bottom Margin', size=20, required=True, help="Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
93
#'margin_right': fields.char('Right Margin', size=20, required=True, help="Numeric value ended with the unit (cm or in). For example 29.7cm or 11in"),
99
def _check_unit(self, cr, uid, ids):
100
for label in self.browse(cr, uid, ids):
101
if label.label_width[-2:] not in ['cm', 'in']:
103
if label.label_height[-2:] not in ['cm', 'in']:
105
if label.width_incr[-2:] not in ['cm', 'in']:
107
if label.height_incr[-2:] not in ['cm', 'in']:
109
if label.margin_top[-2:] not in ['cm', 'in']:
111
if label.margin_left[-2:] not in ['cm', 'in']:
116
(_check_unit, 'Error! Some sizes do not have the unit (cm or in) at the end.', [])