fix: handle names with parenthesis
This commit is contained in:
parent
98e6f6ae3f
commit
7b32b96cfc
3 changed files with 25 additions and 6 deletions
|
|
@ -697,6 +697,7 @@ def create_desktop_icons_from_workspace():
|
||||||
if w.module:
|
if w.module:
|
||||||
app_name = w.app or frappe.db.get_value("Module Def", w.module, "app_name")
|
app_name = w.app or frappe.db.get_value("Module Def", w.module, "app_name")
|
||||||
if app_name in frappe.get_installed_apps():
|
if app_name in frappe.get_installed_apps():
|
||||||
|
icon.app_name = app_name
|
||||||
app_title = frappe.get_hooks("app_title", app_name=app_name)[0]
|
app_title = frappe.get_hooks("app_title", app_name=app_name)[0]
|
||||||
app_icon = frappe.db.exists("Desktop Icon", {"label": app_title, "icon_type": "App"})
|
app_icon = frappe.db.exists("Desktop Icon", {"label": app_title, "icon_type": "App"})
|
||||||
if app_icon:
|
if app_icon:
|
||||||
|
|
@ -744,6 +745,7 @@ def create_desktop_icons_from_installed_apps():
|
||||||
icon.standard = 1
|
icon.standard = 1
|
||||||
icon.idx = index
|
icon.idx = index
|
||||||
icon.icon_type = "App"
|
icon.icon_type = "App"
|
||||||
|
icon.app = a
|
||||||
icon.link = app_details[0]["route"]
|
icon.link = app_details[0]["route"]
|
||||||
icon.logo_url = app_details[0]["logo"]
|
icon.logo_url = app_details[0]["logo"]
|
||||||
if not frappe.db.exists("Desktop Icon", [{"label": icon.label, "icon_type": icon.icon_type}]):
|
if not frappe.db.exists("Desktop Icon", [{"label": icon.label, "icon_type": icon.icon_type}]):
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,9 @@ class SiteMigration:
|
||||||
print("Removing orphan doctypes...")
|
print("Removing orphan doctypes...")
|
||||||
frappe.model.sync.remove_orphan_doctypes()
|
frappe.model.sync.remove_orphan_doctypes()
|
||||||
|
|
||||||
|
frappe.model.sync.remove_orphan_entities()
|
||||||
|
frappe.model.sync.delete_duplicate_icons()
|
||||||
|
|
||||||
print("Syncing portal menu...")
|
print("Syncing portal menu...")
|
||||||
frappe.get_single("Portal Settings").sync_menu()
|
frappe.get_single("Portal Settings").sync_menu()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ perms will get synced only if none exist
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.cache_manager import clear_controller_cache
|
from frappe.cache_manager import clear_controller_cache
|
||||||
|
|
@ -235,12 +236,25 @@ def check_if_record_exists(type=None, path=None, entity_type=None, name=None, mo
|
||||||
scrubbed_entity_type = frappe.scrub(entity_type.lower())
|
scrubbed_entity_type = frappe.scrub(entity_type.lower())
|
||||||
if scrubbed_entity_type == "dashboard" and module_name:
|
if scrubbed_entity_type == "dashboard" and module_name:
|
||||||
scrubbed_entity_type = f"{frappe.scrub(module_name.lower())}_dashboard"
|
scrubbed_entity_type = f"{frappe.scrub(module_name.lower())}_dashboard"
|
||||||
if type == "app":
|
|
||||||
entity_path = os.path.join(path, scrubbed_entity_type, f"{scrubbed_name}.json")
|
def build_path(entity_name):
|
||||||
else:
|
if type == "app":
|
||||||
entity_path = os.path.join(path, scrubbed_entity_type, scrubbed_name, f"{scrubbed_name}.json")
|
return os.path.join(path, scrubbed_entity_type, f"{entity_name}.json")
|
||||||
print(entity_path)
|
return os.path.join(path, scrubbed_entity_type, entity_name, f"{entity_name}.json")
|
||||||
return os.path.exists(entity_path)
|
|
||||||
|
entity_path = build_path(scrubbed_name)
|
||||||
|
if os.path.exists(entity_path):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# This will handle names with brackets Eg: Item Balance (Simple)
|
||||||
|
if "(" in name:
|
||||||
|
cleaned_name = re.sub(r"\s*\([^)]*\)", "", name)
|
||||||
|
scrubbed_cleaned = frappe.scrub(cleaned_name)
|
||||||
|
cleaned_path = build_path(scrubbed_cleaned)
|
||||||
|
if os.path.exists(cleaned_path):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def delete_duplicate_icons():
|
def delete_duplicate_icons():
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue