fix: sync app dashboard on app install (backport #18089)version-14
@@ -420,6 +420,9 @@ def install_app(context, apps, force=False): | |||||
print(f"An error occurred while installing {app}{err_msg}") | print(f"An error occurred while installing {app}{err_msg}") | ||||
exit_code = 1 | exit_code = 1 | ||||
if not exit_code: | |||||
frappe.db.commit() | |||||
frappe.destroy() | frappe.destroy() | ||||
sys.exit(exit_code) | sys.exit(exit_code) | ||||
@@ -11,6 +11,7 @@ import click | |||||
import frappe | import frappe | ||||
from frappe.defaults import _clear_cache | from frappe.defaults import _clear_cache | ||||
from frappe.utils import cint, is_git_url | from frappe.utils import cint, is_git_url | ||||
from frappe.utils.dashboard import sync_dashboards | |||||
def _is_scheduler_enabled() -> bool: | def _is_scheduler_enabled() -> bool: | ||||
@@ -301,6 +302,7 @@ def install_app(name, verbose=False, set_as_patched=True, force=False): | |||||
sync_jobs() | sync_jobs() | ||||
sync_fixtures(name) | sync_fixtures(name) | ||||
sync_customizations(name) | sync_customizations(name) | ||||
sync_dashboards(name) | |||||
for after_sync in app_hooks.after_sync or []: | for after_sync in app_hooks.after_sync or []: | ||||
frappe.get_attr(after_sync)() # | frappe.get_attr(after_sync)() # | ||||
@@ -84,13 +84,8 @@ def get_dashboards_with_link(docname, doctype): | |||||
def sync_dashboards(app=None): | def sync_dashboards(app=None): | ||||
"""Import, overwrite fixtures from `[app]/fixtures`""" | |||||
if not cint(frappe.db.get_single_value("System Settings", "setup_complete")): | |||||
return | |||||
if app: | |||||
apps = [app] | |||||
else: | |||||
apps = frappe.get_installed_apps() | |||||
"""Import, overwrite dashboards from `[app]/[app]_dashboard`""" | |||||
apps = [app] if app else frappe.get_installed_apps() | |||||
for app_name in apps: | for app_name in apps: | ||||
print(f"Updating Dashboard for {app_name}") | print(f"Updating Dashboard for {app_name}") | ||||
@@ -25,8 +25,6 @@ def sync_fixtures(app=None): | |||||
frappe.flags.in_fixtures = False | frappe.flags.in_fixtures = False | ||||
frappe.db.commit() | |||||
def import_custom_scripts(app): | def import_custom_scripts(app): | ||||
"""Import custom scripts from `[app]/fixtures/custom_scripts`""" | """Import custom scripts from `[app]/fixtures/custom_scripts`""" | ||||