mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-06 03:52:15 +00:00
Merge pull request #52938 from frappe/mergify/bp/version-16-hotfix/pr-52889
feat: default letterhead and print format (backport #52889)
This commit is contained in:
@@ -18,8 +18,19 @@ class TestProcessStatementOfAccounts(AccountsTestMixin, IntegrationTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
letterhead = frappe.get_doc("Letter Head", "Company Letterhead - Grey")
|
||||
letterhead.is_default = 0
|
||||
letterhead.save()
|
||||
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super().tearDownClass()
|
||||
letterhead = frappe.get_doc("Letter Head", "Company Letterhead - Grey")
|
||||
letterhead.is_default = 1
|
||||
letterhead.save()
|
||||
frappe.db.commit() # nosemgrep
|
||||
|
||||
def setUp(self):
|
||||
self.create_company()
|
||||
self.create_customer()
|
||||
|
||||
@@ -35,6 +35,7 @@ def after_install():
|
||||
update_roles()
|
||||
make_default_operations()
|
||||
update_pegged_currencies()
|
||||
set_default_print_formats()
|
||||
create_letter_head()
|
||||
frappe.db.commit()
|
||||
|
||||
@@ -301,6 +302,35 @@ def update_pegged_currencies():
|
||||
doc.save()
|
||||
|
||||
|
||||
def set_default_print_formats():
|
||||
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",
|
||||
}
|
||||
|
||||
for doctype, print_format in default_map.items():
|
||||
if frappe.get_meta(doctype).default_print_format:
|
||||
continue
|
||||
|
||||
if not frappe.db.exists("Print Format", print_format):
|
||||
continue
|
||||
|
||||
frappe.make_property_setter(
|
||||
{
|
||||
"doctype": doctype,
|
||||
"doctype_or_field": "DocType",
|
||||
"property": "default_print_format",
|
||||
"value": print_format,
|
||||
"property_type": "Link",
|
||||
},
|
||||
validate_fields_for_doctype=False,
|
||||
)
|
||||
|
||||
|
||||
def create_letter_head():
|
||||
base_path = frappe.get_app_path("erpnext", "accounts", "letterhead")
|
||||
|
||||
@@ -318,6 +348,7 @@ def create_letter_head():
|
||||
"letter_head_name": name,
|
||||
"source": "HTML",
|
||||
"content": content,
|
||||
"is_default": 1 if name == "Company Letterhead - Grey" else 0,
|
||||
}
|
||||
)
|
||||
doc.insert(ignore_permissions=True)
|
||||
|
||||
Reference in New Issue
Block a user