From e818ef22f7cef50672979beb1dff8a5ca9e956f4 Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Fri, 14 Feb 2025 16:27:10 +0530 Subject: [PATCH] fix: make pdf_generator select field As per review, renamed chrome_pdf_generator to pdf_generator and made it a select field. - default option available for select is wkhtmltopdf. - default for new print formats is wkhtmltopdf. - print designer on install adds a new option ( chrome ) to the select field. - added patch to update existing print format to wkhtmltopdf. --- frappe/patches.txt | 1 + .../doctype/print_format/patches/__init__.py | 0 ...htmltopdf_as_default_for_pdf_generator_field.py | 7 +++++++ .../doctype/print_format/print_format.json | 14 +++++++------- 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 frappe/printing/doctype/print_format/patches/__init__.py create mode 100644 frappe/printing/doctype/print_format/patches/sets_wkhtmltopdf_as_default_for_pdf_generator_field.py diff --git a/frappe/patches.txt b/frappe/patches.txt index 4d51a2ce96..b3d42a656d 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -242,3 +242,4 @@ execute:frappe.db.set_single_value("Workspace Settings", "workspace_setup_comple frappe.patches.v16_0.add_app_launcher_in_navbar_settings frappe.desk.doctype.workspace.patches.update_app frappe.patches.v16_0.move_role_desk_settings_to_user +frappe.printing.doctype.print_format.patches.sets_wkhtmltopdf_as_default_for_pdf_generator_field diff --git a/frappe/printing/doctype/print_format/patches/__init__.py b/frappe/printing/doctype/print_format/patches/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/doctype/print_format/patches/sets_wkhtmltopdf_as_default_for_pdf_generator_field.py b/frappe/printing/doctype/print_format/patches/sets_wkhtmltopdf_as_default_for_pdf_generator_field.py new file mode 100644 index 0000000000..ccc44c8ad1 --- /dev/null +++ b/frappe/printing/doctype/print_format/patches/sets_wkhtmltopdf_as_default_for_pdf_generator_field.py @@ -0,0 +1,7 @@ +import frappe + + +def execute(): + """sets "wkhtmltopdf" as default for pdf_generator field""" + for pf in frappe.get_all("Print Format", pluck="name"): + frappe.db.set_value("Print Format", pf, "pdf_generator", "wkhtmltopdf") diff --git a/frappe/printing/doctype/print_format/print_format.json b/frappe/printing/doctype/print_format/print_format.json index 584ac9b509..b8654a0816 100644 --- a/frappe/printing/doctype/print_format/print_format.json +++ b/frappe/printing/doctype/print_format/print_format.json @@ -13,7 +13,7 @@ "standard", "custom_format", "disabled", - "chrome_pdf_generator", + "pdf_generator", "section_break_6", "print_format_type", "raw_printing", @@ -258,17 +258,17 @@ "options": "Hide\nTop Left\nTop Center\nTop Right\nBottom Left\nBottom Center\nBottom Right" }, { - "default": "0", - "description": "Print Designer should be installed to use Chrome.", - "fieldname": "chrome_pdf_generator", - "fieldtype": "Check", - "label": "Use Chrome PDF Generator" + "default": "wkhtmltopdf", + "fieldname": "pdf_generator", + "fieldtype": "Select", + "label": "PDF Generator", + "options": "wkhtmltopdf" } ], "icon": "fa fa-print", "idx": 1, "links": [], - "modified": "2025-02-13 18:39:24.319650", + "modified": "2025-02-14 14:49:39.181074", "modified_by": "Administrator", "module": "Printing", "name": "Print Format",