mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] base_report_to_printer - replace lpr by use of pycups
This commit is contained in:
@@ -223,7 +223,17 @@ class res_users(orm.Model):
|
|||||||
|
|
||||||
class report_xml(orm.Model):
|
class report_xml(orm.Model):
|
||||||
|
|
||||||
def print_direct(self, cr, uid, result, format, printer):
|
|
||||||
|
def set_print_options(self, cr, uid, format, printer, context=None):
|
||||||
|
"""
|
||||||
|
Hook to set print options
|
||||||
|
"""
|
||||||
|
options = {}
|
||||||
|
if format == 'raw':
|
||||||
|
options['raw'] = True
|
||||||
|
return options
|
||||||
|
|
||||||
|
def print_direct(self, cr, uid, result, format, printer, context=None):
|
||||||
fd, file_name = mkstemp()
|
fd, file_name = mkstemp()
|
||||||
try:
|
try:
|
||||||
os.write(fd, base64.decodestring(result))
|
os.write(fd, base64.decodestring(result))
|
||||||
@@ -235,16 +245,13 @@ class report_xml(orm.Model):
|
|||||||
printer_system_name = printer
|
printer_system_name = printer
|
||||||
else:
|
else:
|
||||||
printer_system_name = printer.system_name
|
printer_system_name = printer.system_name
|
||||||
if format == 'raw':
|
connection = cups.Connection()
|
||||||
# -l is the same as -o raw
|
|
||||||
cmd = "lpr -l -P %s %s" % (printer_system_name,file_name)
|
options = self.set_options(cr, uid, format, printer, context=context)
|
||||||
#cmd = "lp -d %s %s" % (printer_system_name,file_name)
|
|
||||||
else:
|
connection.printFile(printer_system_name, file_name, file_name, options={})
|
||||||
cmd = "lpr -P %s %s" % (printer_system_name,file_name)
|
|
||||||
#cmd = "lp -d %s %s" % (printer_system_name,file_name)
|
|
||||||
logger = logging.getLogger('base_report_to_printer')
|
logger = logging.getLogger('base_report_to_printer')
|
||||||
logger.info("Printing job : '%s'" % cmd)
|
logger.info("Printing job : '%s'" % file_name)
|
||||||
os.system(cmd)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_inherit = 'ir.actions.report.xml'
|
_inherit = 'ir.actions.report.xml'
|
||||||
|
|||||||
Reference in New Issue
Block a user