mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
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.
This commit is contained in:
@@ -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
|
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
|
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
|
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.
|
<https://www.cups.org/doc/man-cupsd.conf.html>` for details.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
|||||||
@@ -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
|
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
|
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
|
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.
|
<https://www.cups.org/doc/man-cupsd.conf.html>` for details.
|
||||||
|
|||||||
@@ -432,7 +432,8 @@ rights to give users the ability to view the print menu.</li>
|
|||||||
of the report (truncated at 80 characters). By default this will not be
|
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
|
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
|
to change the configuration of your CUPS server and set the JobPrivateValue
|
||||||
directive to “job-name”, and reload the server. See <cite>cupsd.conf(5)
|
directive to “none” (or some other list of values which does not include
|
||||||
|
“job-name”) , and reload the server. See <cite>cupsd.conf(5)
|
||||||
<https://www.cups.org/doc/man-cupsd.conf.html></cite> for details.</p>
|
<https://www.cups.org/doc/man-cupsd.conf.html></cite> for details.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="usage">
|
<div class="section" id="usage">
|
||||||
|
|||||||
@@ -27,13 +27,18 @@ class PrintAttachment(models.TransientModel):
|
|||||||
errors = []
|
errors = []
|
||||||
for att_line in self.attachment_line_ids:
|
for att_line in self.attachment_line_ids:
|
||||||
data = att_line.attachment_id.datas
|
data = att_line.attachment_id.datas
|
||||||
|
title = att_line.attachment_id.store_fname
|
||||||
if not data:
|
if not data:
|
||||||
errors.append(att_line)
|
errors.append(att_line)
|
||||||
continue
|
continue
|
||||||
content = base64.b64decode(data)
|
content = base64.b64decode(data)
|
||||||
content_format = att_line.get_format()
|
content_format = att_line.get_format()
|
||||||
self.printer_id.print_document(
|
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:
|
if errors:
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user