|
|
@@ -162,11 +162,13 @@ def get_email_queue(recipients, sender, subject, **kwargs): |
|
|
|
e.priority = kwargs.get('send_priority') |
|
|
|
attachments = kwargs.get('attachments') |
|
|
|
if attachments: |
|
|
|
# store attachments with fid, to be attached on-demand later |
|
|
|
# store attachments with fid or print format details, to be attached on-demand later |
|
|
|
_attachments = [] |
|
|
|
for att in attachments: |
|
|
|
if att.get('fid'): |
|
|
|
_attachments.append(att) |
|
|
|
elif att.get("print_format_attachment") == 1: |
|
|
|
_attachments.append(att) |
|
|
|
e.attachments = json.dumps(_attachments) |
|
|
|
|
|
|
|
try: |
|
|
@@ -517,17 +519,22 @@ def prepare_message(email, recipient, recipients_list): |
|
|
|
for attachment in attachments: |
|
|
|
if attachment.get('fcontent'): continue |
|
|
|
|
|
|
|
fid = attachment.get('fid') |
|
|
|
if not fid: continue |
|
|
|
|
|
|
|
fname, fcontent = get_file(fid) |
|
|
|
attachment.update({ |
|
|
|
'fname': fname, |
|
|
|
'fcontent': fcontent, |
|
|
|
'parent': msg_obj |
|
|
|
}) |
|
|
|
attachment.pop("fid", None) |
|
|
|
add_attachment(**attachment) |
|
|
|
fid = attachment.get("fid") |
|
|
|
if fid: |
|
|
|
fname, fcontent = get_file(fid) |
|
|
|
attachment.update({ |
|
|
|
'fname': fname, |
|
|
|
'fcontent': fcontent, |
|
|
|
'parent': msg_obj |
|
|
|
}) |
|
|
|
attachment.pop("fid", None) |
|
|
|
add_attachment(**attachment) |
|
|
|
|
|
|
|
elif attachment.get("print_format_attachment") == 1: |
|
|
|
attachment.pop("print_format_attachment", None) |
|
|
|
print_format_file = frappe.attach_print(**attachment) |
|
|
|
print_format_file.update({"parent": msg_obj}) |
|
|
|
add_attachment(**print_format_file) |
|
|
|
|
|
|
|
return msg_obj.as_string() |
|
|
|
|
|
|
|