fix: handle fixture syncing for missing doctypes
This commit is contained in:
parent
a8557d8796
commit
f7abf3b1cf
1 changed files with 20 additions and 4 deletions
|
|
@ -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")):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue