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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

134 lines
2.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
from __future__ import unicode_literals
import frappe
from frappe import _
from .operations import company_setup
from .operations import install_fixtures as fixtures
from .operations import sample_data
2013-10-08 12:29:11 +00:00
def get_setup_stages(args=None):
if frappe.db.sql("select name from tabCompany"):
stages = [
{
'status': _('Wrapping up'),
'fail_msg': _('Failed to login'),
'tasks': [
{
'fn': fin,
'args': args,
'fail_msg': _("Failed to login")
}
]
}
]
else:
stages = [
{
'status': _('Installing presets'),
'fail_msg': _('Failed to install presets'),
'tasks': [
{
'fn': stage_fixtures,
'args': args,
'fail_msg': _("Failed to install presets")
}
]
},
{
'status': _('Setting up company'),
'fail_msg': _('Failed to setup company'),
'tasks': [
{
'fn': setup_company,
'args': args,
'fail_msg': _("Failed to setup company")
}
]
},
{
'status': _('Setting defaults'),
'fail_msg': 'Failed to set defaults',
'tasks': [
2018-12-12 08:17:43 +00:00
{
'fn': setup_defaults,
'args': args,
'fail_msg': _("Failed to setup defaults")
},
{
'fn': stage_four,
'args': args,
'fail_msg': _("Failed to create website")
2019-09-30 08:10:02 +00:00
},
{
'fn': set_active_domains,
'args': args,
'fail_msg': _("Failed to add Domain")
},
]
},
{
'status': _('Wrapping up'),
'fail_msg': _('Failed to login'),
'tasks': [
{
'fn': fin,
'args': args,
'fail_msg': _("Failed to login")
}
]
}
]
return stages
def stage_fixtures(args):
2018-11-20 18:08:19 +00:00
fixtures.install(args.get('country'))
def setup_company(args):
fixtures.install_company(args)
2018-12-12 08:17:43 +00:00
def setup_defaults(args):
fixtures.install_defaults(frappe._dict(args))
2018-12-12 07:18:12 +00:00
def stage_four(args):
company_setup.create_website(args)
company_setup.create_email_digest()
company_setup.create_logo(args)
def fin(args):
frappe.local.message_log = []
login_as_first_user(args)
make_sample_data(args.get('domains'))
def make_sample_data(domains):
try:
sample_data.make_sample_data(domains)
2021-09-01 09:10:56 +00:00
except Exception:
# clear message
if frappe.message_log:
frappe.message_log.pop()
pass
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)
stage_four(args)
fin(args)
2019-09-30 08:10:02 +00:00
def set_active_domains(args):
domain_settings = frappe.get_single('Domain Settings')
2019-09-30 10:32:24 +00:00
domain_settings.set_active_domains(args.get('domains'))