brotherton-erpnext/erpnext/setup/setup_wizard/setup_wizard.py

77 lines
1.8 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2013-10-08 12:29:11 +00:00
# License: GNU General Public License v3. See license.txt
import frappe
from frappe import _
from .operations import install_fixtures as fixtures
2013-10-08 12:29:11 +00:00
def get_setup_stages(args=None):
if frappe.db.sql("select name from tabCompany"):
stages = [
{
2022-03-28 13:22:46 +00:00
"status": _("Wrapping up"),
"fail_msg": _("Failed to login"),
"tasks": [{"fn": fin, "args": args, "fail_msg": _("Failed to login")}],
}
]
else:
stages = [
{
2022-03-28 13:22:46 +00:00
"status": _("Installing presets"),
"fail_msg": _("Failed to install presets"),
"tasks": [{"fn": stage_fixtures, "args": args, "fail_msg": _("Failed to install presets")}],
},
{
2022-03-28 13:22:46 +00:00
"status": _("Setting up company"),
"fail_msg": _("Failed to setup company"),
"tasks": [{"fn": setup_company, "args": args, "fail_msg": _("Failed to setup company")}],
},
{
2022-03-28 13:22:46 +00:00
"status": _("Setting defaults"),
"fail_msg": "Failed to set defaults",
"tasks": [
{"fn": setup_defaults, "args": args, "fail_msg": _("Failed to setup defaults")},
],
},
{
2022-03-28 13:22:46 +00:00
"status": _("Wrapping up"),
"fail_msg": _("Failed to login"),
"tasks": [{"fn": fin, "args": args, "fail_msg": _("Failed to login")}],
},
]
return stages
2022-03-28 13:22:46 +00:00
def stage_fixtures(args):
2022-03-28 13:22:46 +00:00
fixtures.install(args.get("country"))
def setup_company(args):
fixtures.install_company(args)
2022-03-28 13:22:46 +00:00
2018-12-12 08:17:43 +00:00
def setup_defaults(args):
fixtures.install_defaults(frappe._dict(args))
2022-03-28 13:22:46 +00:00
def fin(args):
frappe.local.message_log = []
login_as_first_user(args)
def login_as_first_user(args):
2016-10-20 10:19:39 +00:00
if args.get("email") and hasattr(frappe.local, "login_manager"):
frappe.local.login_manager.login_as(args.get("email"))
2018-12-12 08:17:43 +00:00
# Only for programmatical use
def setup_complete(args=None):
stage_fixtures(args)
setup_company(args)
setup_defaults(args)
fin(args)