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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user