[refactor] install fix
This commit is contained in:
parent
470462cda6
commit
a045967331
3 changed files with 21 additions and 12 deletions
|
|
@ -98,7 +98,9 @@ def delete_from_table(doctype, name, ignore_doctypes, doc):
|
|||
return frappe.db.sql_list("""select options from `tab{}` where fieldtype='Table'
|
||||
and parent=%s""".format(field_doctype), doctype)
|
||||
|
||||
tables = get_table_fields("DocField") + get_table_fields("Custom Field")
|
||||
tables = get_table_fields("DocField")
|
||||
if not frappe.flags.in_install_app=="frappe":
|
||||
tables += get_table_fields("Custom Field")
|
||||
|
||||
# delete from child tables
|
||||
for t in list(set(tables)):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from __future__ import unicode_literals
|
|||
perms will get synced only if none exist
|
||||
"""
|
||||
import frappe
|
||||
import os, sys
|
||||
import os
|
||||
from frappe.modules.import_file import import_file_by_path
|
||||
from frappe.modules.patch_handler import block_user
|
||||
from frappe.utils import update_progress_bar
|
||||
|
|
@ -24,9 +24,18 @@ def sync_all(force=0, verbose=False):
|
|||
|
||||
def sync_for(app_name, force=0, sync_everything = False, verbose=False):
|
||||
files = []
|
||||
|
||||
if app_name == "frappe":
|
||||
# these need to go first at time of install
|
||||
for d in (("core", "docfield"), ("core", "docperm"), ("core", "doctype"),
|
||||
("core", "user"), ("core", "role"), ("custom", "custom_field"),
|
||||
("custom", "property_setter")):
|
||||
files.append(os.path.join(frappe.get_app_path("frappe"), d[0],
|
||||
"doctype", d[1], d[1] + ".json"))
|
||||
|
||||
for module_name in frappe.local.app_modules.get(app_name) or []:
|
||||
folder = os.path.dirname(frappe.get_module(app_name + "." + module_name).__file__)
|
||||
files += get_doc_files(folder, force, sync_everything, verbose=verbose)
|
||||
get_doc_files(files, folder, force, sync_everything, verbose=verbose)
|
||||
|
||||
l = len(files)
|
||||
if l:
|
||||
|
|
@ -42,22 +51,17 @@ def sync_for(app_name, force=0, sync_everything = False, verbose=False):
|
|||
print ""
|
||||
|
||||
|
||||
def get_doc_files(start_path, force=0, sync_everything = False, verbose=False):
|
||||
def get_doc_files(files, start_path, force=0, sync_everything = False, verbose=False):
|
||||
"""walk and sync all doctypes and pages"""
|
||||
|
||||
out = []
|
||||
document_type = ['doctype', 'page', 'report', 'print_format']
|
||||
for doctype in document_type:
|
||||
doctype_path = os.path.join(start_path, doctype)
|
||||
if os.path.exists(doctype_path):
|
||||
|
||||
# Note: sorted is a hack because custom* and doc* need
|
||||
# be synced first
|
||||
|
||||
for docname in sorted(os.listdir(doctype_path)):
|
||||
for docname in os.listdir(doctype_path):
|
||||
if os.path.isdir(os.path.join(doctype_path, docname)):
|
||||
doc_path = os.path.join(doctype_path, docname, docname) + ".json"
|
||||
if os.path.exists(doc_path):
|
||||
out.append(doc_path)
|
||||
|
||||
return out
|
||||
if not doc_path in files:
|
||||
files.append(doc_path)
|
||||
|
|
|
|||
|
|
@ -62,8 +62,11 @@ def before_tests():
|
|||
|
||||
def import_country_and_currency():
|
||||
from frappe.geo.country_info import get_all
|
||||
print "Importing Geo..."
|
||||
|
||||
data = get_all()
|
||||
|
||||
|
||||
for name in data:
|
||||
country = frappe._dict(data[name])
|
||||
add_country_and_currency(name, country)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue