fix: Add demo setup check in setup wizard

This commit is contained in:
Deepesh Garg 2023-07-07 10:49:56 +05:30
parent d5bdd9387a
commit bb5387fa5d
5 changed files with 25 additions and 1 deletions

View File

@ -20,6 +20,7 @@
"public/js/queries.js",
"public/js/sms_manager.js",
"public/js/utils/party.js",
"public/js/utils/demo.js",
"public/js/controllers/stock_controller.js",
"public/js/payment/payments.js",
"public/js/controllers/taxes_and_totals.js",

View File

@ -38,6 +38,7 @@ erpnext.setup.slides_settings = [
{ fieldname: 'fy_start_date', label: __('Financial Year Begins On'), fieldtype: 'Date', reqd: 1 },
// end date should be hidden (auto calculated)
{ fieldname: 'fy_end_date', label: __('End Date'), fieldtype: 'Date', reqd: 1, hidden: 1 },
{ fieldname: 'setup_demo', label: __('Generate dummy data for demo'), fieldtype: 'Check'},
],
onload: function (slide) {

View File

@ -0,0 +1,11 @@
$(document).on("toolbar_setup", function() {
if (erpnext.is_demo_company_setup) {
console.log("setup");
}
});
erpnext.is_demo_company_setup = function() {
frappe.db.get_value("Global Default", "Global Default", "demo_company", function(r) {
console.log(r);
});
};

View File

@ -28,7 +28,7 @@ def clear_demo_data():
def create_demo_company():
company = erpnext.get_default_company()
company = frappe.db.get_all("Company")[0].name
company_doc = frappe.get_doc("Company", company)
# Make a dummy company

View File

@ -5,6 +5,7 @@
import frappe
from frappe import _
from ..demo import setup_demo_data
from .operations import install_fixtures as fixtures
@ -36,6 +37,11 @@ def get_setup_stages(args=None):
{"fn": setup_defaults, "args": args, "fail_msg": _("Failed to setup defaults")},
],
},
{
"status": _("Setting up demo data"),
"fail_msg": _("Failed to setup demo data"),
"tasks": [{"fn": setup_demo, "args": args, "fail_msg": _("Failed to login")}],
},
{
"status": _("Wrapping up"),
"fail_msg": _("Failed to login"),
@ -63,6 +69,11 @@ def fin(args):
login_as_first_user(args)
def setup_demo(args):
if args.get("setup_demo"):
setup_demo_data()
def login_as_first_user(args):
if args.get("email") and hasattr(frappe.local, "login_manager"):
frappe.local.login_manager.login_as(args.get("email"))