feat: default new sites to the Modern with Images print formats

Point set_default_print_formats() at the new builder-made
"<Doctype> Modern with Images" formats, falling back to the existing
"with Item Image" formats when the new ones aren't present. Only fresh
sites are affected (the existing default-print-format guard is kept).
This commit is contained in:
khushi8112
2026-07-28 11:00:31 +05:30
parent 14fd045555
commit 3eb924d052

View File

@@ -345,22 +345,28 @@ def update_pegged_currencies():
def set_default_print_formats():
# For each doctype, prefer the newer builder-made "Modern with Images" format,
# falling back to the older "with Item Image" format if it isn't present.
default_map = {
"Sales Order": "Sales Order with Item Image",
"Sales Invoice": "Sales Invoice with Item Image",
"Delivery Note": "Delivery Note with Item Image",
"Purchase Order": "Purchase Order with Item Image",
"Purchase Invoice": "Purchase Invoice with Item Image",
"POS Invoice": "POS Invoice with Item Image",
"Quotation": "Quotation with Item Image",
"Request for Quotation": "Request for Quotation with Item Image",
"Sales Order": ["Sales Order Modern with Images", "Sales Order with Item Image"],
"Sales Invoice": ["Sales Invoice Modern with Images", "Sales Invoice with Item Image"],
"Delivery Note": ["Delivery Note Modern with Images", "Delivery Note with Item Image"],
"Purchase Order": ["Purchase Order Modern with Images", "Purchase Order with Item Image"],
"Purchase Invoice": ["Purchase Invoice Modern with Images", "Purchase Invoice with Item Image"],
"POS Invoice": ["POS Invoice Modern with Images", "POS Invoice with Item Image"],
"Quotation": ["Quotation Modern with Images", "Quotation with Item Image"],
"Request for Quotation": [
"Request for Quotation Modern with Images",
"Request for Quotation with Item Image",
],
}
for doctype, print_format in default_map.items():
for doctype, print_formats in default_map.items():
if frappe.get_meta(doctype).default_print_format:
continue
if not frappe.db.exists("Print Format", print_format):
print_format = next((pf for pf in print_formats if frappe.db.exists("Print Format", pf)), None)
if not print_format:
continue
frappe.make_property_setter(