1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2009 Ferran Pegueroles <ferran@pegueroles.com>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
35
from tempfile import mkstemp
37
print_form = '''<?xml version="1.0"?>
38
<form string="Printing">
39
<field name="printer" />
42
'printer' : {'string':'Printer', 'type':'many2one', 'relation':'printjob.printer','required':True},
45
class wizard_reprint(wizard.interface):
47
def _get_default_printer(self, cr, uid, data, context):
49
pool = pooler.get_pool(cr.dbname)
50
printer_ids = pool.get('printjob.printer').search(cr, uid,[('is_default','=',True)])
52
data['form']['printer'] = printer_ids[0]
55
def _print(self, cr, uid, data, context):
56
pool= pooler.get_pool(cr.dbname)
57
printer_obj = pool.get('printjob.printer')
58
printer_reg = printer_obj.read(cr, uid, [data['form']['printer']])[0]
59
job_obj = pool.get('printjob.job')
60
job_reg = job_obj.read(cr, uid, data['ids'])[0]
62
os.write(tmpfile[0],base64.decodestring(job_reg['result']))
63
os.system("lpr -P %s %s" % (printer_reg['system_name'],tmpfile[1]))
68
'actions': [_get_default_printer],
69
'result': {'type':'form', 'arch':print_form, 'fields':print_fields, 'state':[('end','Cancelar'),('print','Imprimir')]}
73
'result': {'type':'state', 'state':'end'}
77
wizard_reprint('printjob.job.reprint')
79
class wizard_preview(wizard.interface):
81
def _get_id(self, cr, uid, data, context):
83
data['form']['ids'] = [ data['id'] ]
89
'result': {'type':'print', 'report':'printjob.reprint', 'get_id_from_action':True ,'state':'end'}
93
wizard_preview('printjob.job.preview')