From 0790d65015bc4298a0c3bf1bead8721032307c50 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Wed, 9 Mar 2022 12:00:36 +0100 Subject: [PATCH] fix(#259): handle case of print attachment wizard The fix in #259 only worked for reports being printed at generation of the PDF. This PR handles sending an attachment to a printer through the Print Attachment wizard. Also clarify the configuration section of the README. --- base_report_to_printer/README.rst | 3 ++- base_report_to_printer/readme/CONFIGURE.rst | 3 ++- base_report_to_printer/static/description/index.html | 3 ++- .../wizards/print_attachment_report.py | 9 +++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/base_report_to_printer/README.rst b/base_report_to_printer/README.rst index e46e8a5..1c659b5 100644 --- a/base_report_to_printer/README.rst +++ b/base_report_to_printer/README.rst @@ -82,7 +82,8 @@ The jobs will be sent to the printer with a name matching the print_report_name of the report (truncated at 80 characters). By default this will not be displayed by CUPS web interface or in Odoo. To see this information, you need to change the configuration of your CUPS server and set the JobPrivateValue -directive to "job-name", and reload the server. See `cupsd.conf(5) +directive to "none" (or some other list of values which does not include +"job-name") , and reload the server. See `cupsd.conf(5) ` for details. Usage diff --git a/base_report_to_printer/readme/CONFIGURE.rst b/base_report_to_printer/readme/CONFIGURE.rst index 0b12368..3463730 100644 --- a/base_report_to_printer/readme/CONFIGURE.rst +++ b/base_report_to_printer/readme/CONFIGURE.rst @@ -8,5 +8,6 @@ The jobs will be sent to the printer with a name matching the print_report_name of the report (truncated at 80 characters). By default this will not be displayed by CUPS web interface or in Odoo. To see this information, you need to change the configuration of your CUPS server and set the JobPrivateValue -directive to "job-name", and reload the server. See `cupsd.conf(5) +directive to "none" (or some other list of values which does not include +"job-name") , and reload the server. See `cupsd.conf(5) ` for details. diff --git a/base_report_to_printer/static/description/index.html b/base_report_to_printer/static/description/index.html index cf2a3f2..31051a1 100644 --- a/base_report_to_printer/static/description/index.html +++ b/base_report_to_printer/static/description/index.html @@ -432,7 +432,8 @@ rights to give users the ability to view the print menu. of the report (truncated at 80 characters). By default this will not be displayed by CUPS web interface or in Odoo. To see this information, you need to change the configuration of your CUPS server and set the JobPrivateValue -directive to “job-name”, and reload the server. See cupsd.conf(5) +directive to “none” (or some other list of values which does not include +“job-name”) , and reload the server. See cupsd.conf(5) <https://www.cups.org/doc/man-cupsd.conf.html> for details.

diff --git a/base_report_to_printer/wizards/print_attachment_report.py b/base_report_to_printer/wizards/print_attachment_report.py index 3addc29..f2160b2 100644 --- a/base_report_to_printer/wizards/print_attachment_report.py +++ b/base_report_to_printer/wizards/print_attachment_report.py @@ -22,18 +22,23 @@ class PrintAttachment(models.TransientModel): ) def print_attachments(self): - """ Prints a label per selected record """ + """Prints a label per selected record""" self.ensure_one() errors = [] for att_line in self.attachment_line_ids: data = att_line.attachment_id.datas + title = att_line.attachment_id.store_fname if not data: errors.append(att_line) continue content = base64.b64decode(data) content_format = att_line.get_format() self.printer_id.print_document( - None, content=content, format=content_format, copies=att_line.copies + None, + content=content, + format=content_format, + copies=att_line.copies, + title=title, ) if errors: return {