From 0d58dfd0fa0824fb593eb7707a2b3f114e0f9eee Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Thu, 25 Sep 2025 11:34:30 +0530 Subject: [PATCH] feat: add default letterhead with HTML template via after_install --- .../accounts/letterhead/letterhead_plain.html | 1 + erpnext/setup/install.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/erpnext/accounts/letterhead/letterhead_plain.html b/erpnext/accounts/letterhead/letterhead_plain.html index 54845f3e401..1dce3c51063 100644 --- a/erpnext/accounts/letterhead/letterhead_plain.html +++ b/erpnext/accounts/letterhead/letterhead_plain.html @@ -28,6 +28,7 @@ max-width: 90px; max-height: 90px; display: inline-block; + border-radius: 15px; } .company-details { width: 40%; diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index fd98e124d70..7a6cff20563 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -2,6 +2,8 @@ # License: GNU General Public License v3. See license.txt +import os + import frappe from frappe import _ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields @@ -34,6 +36,7 @@ def after_install(): update_roles() make_default_operations() update_pegged_currencies() + create_letter_head() frappe.db.commit() @@ -279,6 +282,38 @@ def update_pegged_currencies(): doc.save() +def create_letter_head(): + base_path = frappe.get_app_path("erpnext", "letterhead") + letterhead_with_background_colour = frappe.read_file( + os.path.join(base_path, "letterhead_with_background_colour.html") + ) + letterhead_plain = frappe.read_file(os.path.join(base_path, "letterhead_plain.html")) + + if not frappe.db.exists("Letter Head", "Letterhead with background colour"): + doc = frappe.get_doc( + { + "doctype": "Letter Head", + "letter_head_name": "Letterhead with background colour", + "source": "HTML", + "content": letterhead_with_background_colour, + } + ) + doc.insert(ignore_permissions=True) + frappe.db.commit() + + if not frappe.db.exists("Letter Head", "Letterhead Plain"): + doc = frappe.get_doc( + { + "doctype": "Letter Head", + "letter_head_name": "Letterhead plain", + "source": "HTML", + "content": letterhead_plain, + } + ) + doc.insert(ignore_permissions=True) + frappe.db.commit() + + DEFAULT_ROLE_PROFILES = { "Inventory": [ "Stock User",