fix: get PDF from printview

Clicking "Get PDF" in printview should result in the same view being converted to PDF. So far, we didn't pass the print format and letterhead, sometimes resulting in an entirely different PDF.
This commit is contained in:
barredterra 2024-11-13 11:22:59 +01:00
parent 504ef2e9e4
commit 834c31aa52
2 changed files with 4 additions and 1 deletions

View file

@ -18,7 +18,7 @@
{{ _("Print") }}
</a>
<a class="p-2"
href="/api/method/frappe.utils.print_format.download_pdf?doctype={{doctype|e}}&name={{name|e}}&key={{key|e}}">
href="/api/method/frappe.utils.print_format.download_pdf?doctype={{doctype|e}}&name={{name|e}}&format={{print_format|e}}&letterhead={{letterhead|e}}&no_letterhead={{no_letterhead|e}}&_lang={{lang|e}}&key={{key|e}}">
{{ _('Get PDF') }}
</a>
</div>

View file

@ -97,6 +97,9 @@ def get_context(context) -> PrintContext:
"doctype": frappe.form_dict.doctype,
"name": frappe.form_dict.name,
"key": frappe.form_dict.get("key"),
"print_format": print_format.name,
"letterhead": letterhead,
"no_letterhead": frappe.form_dict.no_letterhead,
}