Пример #1
0
def add_module_defs(app):
	modules = frappe.get_module_list(app)
	for module in modules:
		d = frappe.new_doc("Module Def")
		d.app_name = app
		d.module_name = module
		d.save(ignore_permissions=True)
Пример #2
0
def add_module_defs(app):
	modules = frappe.get_module_list(app)
	for module in modules:
		d = frappe.new_doc("Module Def")
		d.app_name = app
		d.module_name = module
		d.save()
Пример #3
0
def add_module_defs(app):
	modules = frappe.get_module_list(app)
	for module in modules:
		d = frappe.new_doc("Module Def")
		d.app_name = app
		d.module_name = module
		d.save(ignore_permissions=True)
Пример #4
0
def add_module_defs(app):
    modules = frappe.get_module_list(app)
    for module in modules:
        d = frappe.new_doc("Module Def")
        d.app_name = app
        d.module_name = module
        d.save()
Пример #5
0
def remove_app(app_name, dry_run=False):
	"""Delete app and all linked to the app's module with the app."""

	if not dry_run:
		confirm = raw_input("All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue (y/n) ? ")
		if confirm!="y":
			return

	from frappe.utils.backups import scheduled_backup
	print "Backing up..."
	scheduled_backup(ignore_files=True)

	# remove modules, doctypes, roles
	for module_name in frappe.get_module_list(app_name):
		for doctype in frappe.get_list("DocType", filters={"module": module_name},
			fields=["name", "issingle"]):
			print "removing {0}...".format(doctype.name)
			# drop table

			if not dry_run:
				if not doctype.issingle:
					frappe.db.sql("drop table `tab{0}`".format(doctype.name))
				frappe.delete_doc("DocType", doctype.name)

		print "removing Module {0}...".format(module_name)
		if not dry_run:
			frappe.delete_doc("Module Def", module_name)

	remove_from_installed_apps(app_name)
Пример #6
0
def remove_app(app_name, dry_run=False, yes=False):
    """Delete app and all linked to the app's module with the app."""

    if not dry_run and not yes:
        confirm = raw_input(
            "All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue (y/n) ? "
        )
        if confirm != "y":
            return

    from frappe.utils.backups import scheduled_backup
    print "Backing up..."
    scheduled_backup(ignore_files=True)

    drop_doctypes = []

    # remove modules, doctypes, roles
    for module_name in frappe.get_module_list(app_name):
        for doctype in frappe.get_list("DocType",
                                       filters={"module": module_name},
                                       fields=["name", "issingle"]):
            print "removing DocType {0}...".format(doctype.name)
            # drop table

            if not dry_run:
                frappe.delete_doc("DocType", doctype.name)

                if not doctype.issingle:
                    drop_doctypes.append(doctype.name)

        # remove reports
        for report in frappe.get_list("Report",
                                      filters={"module": module_name}):
            print "removing {0}...".format(report.name)
            if not dry_run:
                frappe.delete_doc("Report", report.name)

        for page in frappe.get_list("Page", filters={"module": module_name}):
            print "removing Page {0}...".format(page.name)
            # drop table

            if not dry_run:
                frappe.delete_doc("Page", page.name)

        print "removing Module {0}...".format(module_name)

        if not dry_run:
            frappe.delete_doc("Module Def", module_name)

    # delete desktop icons
    frappe.db.sql('delete from `tabDesktop Icon` where app=%s', app_name)

    remove_from_installed_apps(app_name)

    if not dry_run:
        # drop tables after a commit
        frappe.db.commit()

        for doctype in set(drop_doctypes):
            frappe.db.sql("drop table `tab{0}`".format(doctype))
Пример #7
0
def remove_app(app_name, dry_run=False, yes=False):
	"""Delete app and all linked to the app's module with the app."""

	if not dry_run and not yes:
		confirm = input("All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue (y/n) ? ")
		if confirm!="y":
			return

	from frappe.utils.backups import scheduled_backup
	print("Backing up...")
	scheduled_backup(ignore_files=True)

	drop_doctypes = []

	# remove modules, doctypes, roles
	for module_name in frappe.get_module_list(app_name):
		for doctype in frappe.get_list("DocType", filters={"module": module_name},
			fields=["name", "issingle"]):
			print("removing DocType {0}...".format(doctype.name))

			if not dry_run:
				frappe.delete_doc("DocType", doctype.name)

				if not doctype.issingle:
					drop_doctypes.append(doctype.name)
Пример #8
0
def remove_app(app_name, dry_run=False, yes=False):
	"""Delete app and all linked to the app's module with the app."""

	if not dry_run and not yes:
		confirm = raw_input("All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue (y/n) ? ")
		if confirm!="y":
			return

	from frappe.utils.backups import scheduled_backup
	print "Backing up..."
	scheduled_backup(ignore_files=True)

	drop_doctypes = []

	# remove modules, doctypes, roles
	for module_name in frappe.get_module_list(app_name):
		for doctype in frappe.get_list("DocType", filters={"module": module_name},
			fields=["name", "issingle"]):
			print "removing DocType {0}...".format(doctype.name)
			# drop table

			if not dry_run:
				frappe.delete_doc("DocType", doctype.name)

				if not doctype.issingle:
					drop_doctypes.append(doctype.name)

		# remove reports
		for report in frappe.get_list("Report", filters={"module": module_name}):
			print "removing {0}...".format(report.name)
			if not dry_run:
				frappe.delete_doc("Report", report.name)

		for page in frappe.get_list("Page", filters={"module": module_name}):
			print "removing Page {0}...".format(page.name)
			# drop table

			if not dry_run:
				frappe.delete_doc("Page", page.name)

		print "removing Module {0}...".format(module_name)

		if not dry_run:
			frappe.delete_doc("Module Def", module_name)

	# delete desktop icons
	frappe.db.sql('delete from `tabDesktop Icon` where app=%s', app_name)

	remove_from_installed_apps(app_name)

	if not dry_run:
		# drop tables after a commit
		frappe.db.commit()

		for doctype in set(drop_doctypes):
			frappe.db.sql("drop table `tab{0}`".format(doctype))
Пример #9
0
def remove_app(app_name, dry_run=False, yes=False):
	"""Delete app and all linked to the app's module with the app."""

	if not dry_run and not yes:
		confirm = input("All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue (y/n) ? ")
		if confirm!="y":
			return

	from frappe.utils.backups import scheduled_backup
	print("Backing up...")
	scheduled_backup(ignore_files=True)

	drop_doctypes = []

	# remove modules, doctypes, roles
	for module_name in frappe.get_module_list(app_name):
		for doctype in frappe.get_list("DocType", filters={"module": module_name},
			fields=["name", "issingle"]):
			print("removing DocType {0}...".format(doctype.name))

			if not dry_run:
				frappe.delete_doc("DocType", doctype.name)

				if not doctype.issingle:
					drop_doctypes.append(doctype.name)

		# remove reports, pages and web forms
		for doctype in ("Report", "Page", "Web Form", "Print Format"):
			for record in frappe.get_list(doctype, filters={"module": module_name}):
				print("removing {0} {1}...".format(doctype, record.name))
				if not dry_run:
					frappe.delete_doc(doctype, record.name)

		# remove data migration plans and linked data migration runs
		for plan in frappe.get_list("Data Migration Plan", filters={"module": module_name}):
			print("removing Data Migration Runs for Data Migration Plan {0}...".format(plan.name))
			for record in frappe.get_list("Data Migration Run", filters={"data_migration_plan": plan.name}):
				if not dry_run:
					frappe.delete_doc("Data Migration Run", record.name)

			print("removing Data Migration Plan {0}...".format(plan.name))
			if not dry_run:
				frappe.delete_doc("Data Migration Plan", plan.name)

		print("removing Module {0}...".format(module_name))
		if not dry_run:
			frappe.delete_doc("Module Def", module_name)

	remove_from_installed_apps(app_name)

	if not dry_run:
		# drop tables after a commit
		frappe.db.commit()

		for doctype in set(drop_doctypes):
			frappe.db.sql("drop table `tab{0}`".format(doctype))
Пример #10
0
def remove_app(app_name,
               dry_run=False,
               yes=False,
               no_backup=False,
               force=False):
    """Remove app and all linked to the app's module with the app from a site."""

    # dont allow uninstall app if not installed unless forced
    if not force:
        if app_name not in frappe.get_installed_apps():
            click.secho("App {0} not installed on Site {1}".format(
                app_name, frappe.local.site),
                        fg="yellow")
            return

    print("Uninstalling App {0} from Site {1}...".format(
        app_name, frappe.local.site))

    if not dry_run and not yes:
        confirm = click.confirm(
            "All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue?"
        )
        if not confirm:
            return

    if not no_backup:
        from frappe.utils.backups import scheduled_backup
        print("Backing up...")
        scheduled_backup(ignore_files=True)

    frappe.flags.in_uninstall = True
    drop_doctypes = []

    # remove modules, doctypes, roles
    for module_name in frappe.get_module_list(app_name):
        for doctype in frappe.get_list("DocType",
                                       filters={"module": module_name},
                                       fields=["name", "issingle"]):
            print("removing DocType {0}...".format(doctype.name))

            if not dry_run:
                frappe.delete_doc("DocType", doctype.name)

                if not doctype.issingle:
                    drop_doctypes.append(doctype.name)

        linked_doctypes = frappe.get_all("DocField",
                                         filters={
                                             "fieldtype": "Link",
                                             "options": "Module Def"
                                         },
                                         fields=['parent'])
        ordered_doctypes = ["Desk Page", "Report", "Page", "Web Form"]
        doctypes_with_linked_modules = ordered_doctypes + [
            doctype.parent for doctype in linked_doctypes
            if doctype.parent not in ordered_doctypes
        ]

        for doctype in doctypes_with_linked_modules:
            for record in frappe.get_list(doctype,
                                          filters={"module": module_name}):
                print("removing {0} {1}...".format(doctype, record.name))
                if not dry_run:
                    frappe.delete_doc(doctype, record.name)

        print("removing Module {0}...".format(module_name))
        if not dry_run:
            frappe.delete_doc("Module Def", module_name)

    remove_from_installed_apps(app_name)

    if not dry_run:
        # drop tables after a commit
        frappe.db.commit()

        for doctype in set(drop_doctypes):
            frappe.db.sql("drop table `tab{0}`".format(doctype))

        click.secho("Uninstalled App {0} from Site {1}".format(
            app_name, frappe.local.site),
                    fg="green")

    frappe.flags.in_uninstall = False