2015-03-03 09:25:30 +00:00
|
|
|
# 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
|
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
import frappe
|
2014-04-18 10:30:41 +00:00
|
|
|
from frappe import _
|
2018-01-30 11:28:49 +00:00
|
|
|
from .operations import install_fixtures, taxes_setup, defaults_setup, company_setup, sample_data
|
2013-10-08 12:29:11 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def get_setup_stages(args=None):
|
2016-09-23 15:13:23 +00:00
|
|
|
if frappe.db.sql("select name from tabCompany"):
|
2017-12-21 06:25:58 +00:00
|
|
|
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 and taxes'),
|
|
|
|
'fail_msg': _('Failed to setup company'),
|
|
|
|
'tasks': [
|
|
|
|
{
|
|
|
|
'fn': setup_company,
|
|
|
|
'args': args,
|
|
|
|
'fail_msg': _("Failed to setup company")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'fn': setup_taxes,
|
|
|
|
'args': args,
|
|
|
|
'fail_msg': _("Failed to setup taxes")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'status': _('Setting defaults'),
|
|
|
|
'fail_msg': 'Failed to set defaults',
|
|
|
|
'tasks': [
|
|
|
|
{
|
|
|
|
'fn': stage_three,
|
|
|
|
'args': args,
|
|
|
|
'fail_msg': _("Failed to set defaults")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'status': _('Making website'),
|
|
|
|
'fail_msg': _('Failed to create website'),
|
|
|
|
'tasks': [
|
|
|
|
{
|
|
|
|
'fn': stage_four,
|
|
|
|
'args': args,
|
|
|
|
'fail_msg': _("Failed to create website")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'status': _('Wrapping up'),
|
|
|
|
'fail_msg': _('Failed to login'),
|
|
|
|
'tasks': [
|
|
|
|
{
|
|
|
|
'fn': fin,
|
|
|
|
'args': args,
|
|
|
|
'fail_msg': _("Failed to login")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
return stages
|
2016-09-23 15:13:23 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def setup_complete(args=None):
|
|
|
|
stage_fixtures(args)
|
|
|
|
setup_company(args)
|
|
|
|
setup_taxes(args)
|
|
|
|
stage_three(args)
|
|
|
|
stage_four(args)
|
|
|
|
fin(args)
|
|
|
|
|
|
|
|
def stage_fixtures(args):
|
2016-09-23 15:13:23 +00:00
|
|
|
install_fixtures.install(args.get("country"))
|
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def setup_company(args):
|
|
|
|
defaults_setup.create_price_lists(args)
|
|
|
|
company_setup.create_fiscal_year_and_company(args)
|
|
|
|
company_setup.enable_shopping_cart(args)
|
|
|
|
company_setup.create_bank_account(args)
|
2016-09-23 15:13:23 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def setup_taxes(args):
|
|
|
|
taxes_setup.create_sales_tax(args)
|
2016-09-23 15:13:23 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def stage_three(args):
|
|
|
|
defaults_setup.create_employee_for_self(args)
|
|
|
|
defaults_setup.set_default_settings(args)
|
|
|
|
defaults_setup.create_territories()
|
|
|
|
defaults_setup.create_feed_and_todo()
|
|
|
|
defaults_setup.set_no_copy_fields_in_variant_settings()
|
2017-12-06 07:58:06 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def stage_four(args):
|
|
|
|
company_setup.create_website(args)
|
|
|
|
company_setup.create_email_digest()
|
|
|
|
company_setup.create_logo(args)
|
2016-09-23 15:13:23 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def fin(args):
|
|
|
|
frappe.local.message_log = []
|
2016-09-23 15:13:23 +00:00
|
|
|
login_as_first_user(args)
|
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
make_sample_data(args.get('domains'))
|
2016-09-23 15:13:23 +00:00
|
|
|
|
2017-12-21 06:25:58 +00:00
|
|
|
def make_sample_data(domains):
|
2017-09-04 05:44:04 +00:00
|
|
|
try:
|
2017-12-21 06:25:58 +00:00
|
|
|
sample_data.make_sample_data(domains)
|
2017-09-04 05:44:04 +00:00
|
|
|
except:
|
|
|
|
# clear message
|
|
|
|
if frappe.message_log:
|
|
|
|
frappe.message_log.pop()
|
|
|
|
pass
|
|
|
|
|
2015-02-17 10:25:36 +00:00
|
|
|
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"))
|