feat: add default letterhead with HTML template via after_install

This commit is contained in:
khushi8112
2025-09-25 11:34:30 +05:30
parent f6ebf2d0b3
commit 0d58dfd0fa
2 changed files with 36 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
max-width: 90px;
max-height: 90px;
display: inline-block;
border-radius: 15px;
}
.company-details {
width: 40%;

View File

@@ -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",