diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py index 7d5cfb90af8..2d599fee1af 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/test_process_statement_of_accounts.py @@ -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() diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index 94706443d6b..726906ac6cb 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -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)