diff --git a/frappe/utils/fixtures.py b/frappe/utils/fixtures.py index 821b1a1187..81e0edbca5 100644 --- a/frappe/utils/fixtures.py +++ b/frappe/utils/fixtures.py @@ -17,15 +17,31 @@ def sync_fixtures(app=None): frappe.flags.in_fixtures = True for app in apps: - fixtures_path = frappe.get_app_path(app, "fixtures") - if os.path.exists(fixtures_path): - import_doc(fixtures_path) - + import_fixtures(app) import_custom_scripts(app) frappe.flags.in_fixtures = False +def import_fixtures(app): + fixtures_path = frappe.get_app_path(app, "fixtures") + if not os.path.exists(fixtures_path): + return + + fixture_files = os.listdir(fixtures_path) + + for fname in fixture_files: + if not fname.endswith(".json"): + continue + + file_path = frappe.get_app_path(app, "fixtures", fname) + try: + import_doc(file_path) + except (ImportError, frappe.DoesNotExistError) as e: + # fixture syncing for missing doctypes + print(f"Skipping fixture syncing from the file {fname}. Reason: {e}") + + def import_custom_scripts(app): """Import custom scripts from `[app]/fixtures/custom_scripts`""" if os.path.exists(frappe.get_app_path(app, "fixtures", "custom_scripts")):