mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] 14.0 base_report_to_printer: improve job title
instead of sending a temporary random file name as the title of the job, use the report file name. Since this is not displayed by default by cups, document how to configure the CUPS server so that the information can be displayed. Clean up the temporary file after printing to avoid cluttering the server in the long run.
This commit is contained in:
committed by
trisdoan
parent
bb755aa9f9
commit
2aa2979416
@@ -175,6 +175,7 @@ class PrintingPrinter(models.Model):
|
||||
def print_file(self, file_name, report=None, **print_opts):
|
||||
""" Print a file """
|
||||
self.ensure_one()
|
||||
title = print_opts.pop("title", file_name)
|
||||
connection = self.server_id._open_connection(raise_on_error=True)
|
||||
options = self.print_options(report=report, **print_opts)
|
||||
|
||||
@@ -182,10 +183,14 @@ class PrintingPrinter(models.Model):
|
||||
"Sending job to CUPS printer %s on %s with options %s"
|
||||
% (self.system_name, self.server_id.address, options)
|
||||
)
|
||||
connection.printFile(self.system_name, file_name, file_name, options=options)
|
||||
connection.printFile(self.system_name, file_name, title, options=options)
|
||||
_logger.info(
|
||||
"Printing job: '{}' on {}".format(file_name, self.server_id.address)
|
||||
)
|
||||
try:
|
||||
os.remove(file_name)
|
||||
except OSError as exc:
|
||||
_logger.warning("Unable to remove temporary file %s: %s", file_name, exc)
|
||||
return True
|
||||
|
||||
def set_default(self):
|
||||
|
||||
Reference in New Issue
Block a user