From 82cc98366d80fda6cd727a7fc4b51c66f1eab6ad Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 29 May 2022 12:57:39 +0530 Subject: [PATCH] fix: dont attempt to init singles that dont exist This is done during app install stage and causes unnecessary failures where stale doctypes are left in db. --- frappe/installer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frappe/installer.py b/frappe/installer.py index 5cd46e618d..c8373ff06f 100644 --- a/frappe/installer.py +++ b/frappe/installer.py @@ -473,13 +473,20 @@ def set_all_patches_as_completed(app): def init_singles(): - singles = [single["name"] for single in frappe.get_all("DocType", filters={"issingle": True})] + singles = frappe.get_all("DocType", filters={"issingle": True}, pluck="name") for single in singles: - if not frappe.db.get_singles_dict(single): + if frappe.db.get_singles_dict(single): + continue + + try: doc = frappe.new_doc(single) doc.flags.ignore_mandatory = True doc.flags.ignore_validate = True doc.save() + except ImportError: + # The doctype exists, but controller is deleted, + # no need to attempt to init such single, ref: #16917 + continue def make_conf(