fix: make filename more user-friendly

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-03-13 13:09:16 +05:30
parent 5a6bff9de7
commit 508e4d9ae3
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -83,6 +83,7 @@ def _download_multi_pdf(
PDF: A PDF generated by the concatenation of the mentioned input docs
"""
filename = ""
import json
@ -94,6 +95,7 @@ def _download_multi_pdf(
if not isinstance(doctype, dict):
result = json.loads(name)
total_docs = len(result)
filename = f"{doctype}_"
# Concatenating pdf files
for idx, ss in enumerate(result):
@ -123,6 +125,7 @@ def _download_multi_pdf(
total_docs = sum([len(doctype[dt]) for dt in doctype])
count = 1
for doctype_name in doctype:
filename += f"{doctype_name}_"
for doc_name in doctype[doctype_name]:
try:
pdf_writer = frappe.get_print(
@ -156,7 +159,7 @@ def _download_multi_pdf(
_file = frappe.get_doc(
{
"doctype": "File",
"file_name": f"{task_id}.pdf",
"file_name": f"{filename}{task_id}.pdf",
"content": merged_pdf.getvalue(),
"is_private": 1,
}