fix: delete desktop icons when app is uninstalled

This commit is contained in:
sokumon 2025-11-19 12:30:15 +05:30
parent 656aaa1f2f
commit a0edd3e3f2
2 changed files with 20 additions and 0 deletions

View file

@ -17,6 +17,7 @@ before_install = "frappe.utils.install.before_install"
after_install = "frappe.utils.install.after_install"
after_app_install = "frappe.utils.install.auto_generate_icons_and_sidebar"
after_app_uninstall = "frappe.utils.install.delete_desktop_icon"
page_js = {"setup-wizard": "public/js/frappe/setup_wizard.js"}

View file

@ -2,6 +2,8 @@
# License: MIT. See LICENSE
import getpass
import click
import frappe
from frappe.geo.doctype.country.country import import_country_and_currency
from frappe.utils import cint
@ -196,3 +198,20 @@ def auto_generate_icons_and_sidebar(app_name=None):
frappe.db.commit() # nosemgrep
except Exception as e:
print(f"Error creating icons {e}")
def delete_desktop_icon(app_name):
frappe.get_hooks(app_name=app_name)
app_title = frappe.get_hooks(app_name=app_name)["app_title"][0]
icons_to_be_deleted = frappe.get_all(
"Desktop Icon",
pluck="name",
or_filters=[
["Desktop Icon", "name", "=", app_title],
["Desktop Icon", "parent_icon", "=", app_title],
],
)
print("Deleting Desktop Icons")
for icon in icons_to_be_deleted:
frappe.delete_doc_if_exists("Desktop Icon", icon)
frappe.db.commit()