From 73517099807939afdec506364d9bb9f995b64e25 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Wed, 6 Dec 2017 13:28:06 +0530 Subject: [PATCH] [multicheck] Select multiple domains in setup (#11709) * [multicheck] select multiple domains in setup * use multiple domains in make_sample_data * revert to setting in domains child table * domains slide validation * update setup wizard test --- erpnext/public/js/setup_wizard.js | 29 ++++++++++--------- erpnext/setup/setup_wizard/data/test_mfg.json | 2 +- erpnext/setup/setup_wizard/sample_data.py | 8 ++--- erpnext/setup/setup_wizard/setup_wizard.py | 8 +++-- .../setup/setup_wizard/test_setup_wizard.py | 3 +- erpnext/utilities/user_progress.py | 5 ++-- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js index ded7cae91d6..71b098ea338 100644 --- a/erpnext/public/js/setup_wizard.js +++ b/erpnext/public/js/setup_wizard.js @@ -15,11 +15,12 @@ erpnext.setup.slides_settings = [ { // Domain name: 'domain', - domains: ["all"], - title: __('Select your Domain'), + title: __('Select your Domains'), fields: [ { - fieldname: 'domain', label: __('Domain'), fieldtype: 'Select', + fieldname: 'domains', + label: __('Domains'), + fieldtype: 'MultiCheck', options: [ { "label": __("Distribution"), "value": "Distribution" }, { "label": __("Manufacturing"), "value": "Manufacturing" }, @@ -32,18 +33,19 @@ erpnext.setup.slides_settings = [ }, ], // help: __('Select the nature of your business.'), - onload: function (slide) { - slide.get_input("domain").on("change", function () { - frappe.setup.domain = $(this).val(); - frappe.wizard.refresh_slides(); - }); + validate: function () { + if (this.values.domains.length === 0) { + frappe.msgprint(__("Please select at least one domain.")); + return false; + } + frappe.setup.domains = this.values.domains; + return true; }, }, { // Brand name: 'brand', - domains: ["all"], icon: "fa fa-bookmark", title: __("The Brand"), // help: __('Upload your letter head and logo. (you can edit them later).'), @@ -57,14 +59,14 @@ erpnext.setup.slides_settings = [ }, { fieldname: 'company_name', - label: frappe.setup.domain === 'Education' ? + label: frappe.setup.domains.includes('Education') ? __('Institute Name') : __('Company Name'), fieldtype: 'Data', reqd: 1 }, { fieldname: 'company_abbr', - label: frappe.setup.domain === 'Education' ? + label: frappe.setup.domains.includes('Education') ? __('Institute Abbreviation') : __('Company Abbreviation'), fieldtype: 'Data' } @@ -100,10 +102,9 @@ erpnext.setup.slides_settings = [ { // Organisation name: 'organisation', - domains: ["all"], title: __("Your Organization"), icon: "fa fa-building", - // help: (frappe.setup.domain === 'Education' ? + // help: frappe.setup.domains.includes('Education') ? // __('The name of the institute for which you are setting up this system.') : // __('The name of your company for which you are setting up this system.')), fields: [ @@ -111,7 +112,7 @@ erpnext.setup.slides_settings = [ fieldname: 'company_tagline', label: __('What does it do?'), fieldtype: 'Data', - placeholder: frappe.setup.domain === 'Education' ? + placeholder: frappe.setup.domains.includes('Education') ? __('e.g. "Primary School" or "University"') : __('e.g. "Build tools for builders"'), reqd: 1 diff --git a/erpnext/setup/setup_wizard/data/test_mfg.json b/erpnext/setup/setup_wizard/data/test_mfg.json index b6ea665c76a..efc5fa83a5e 100644 --- a/erpnext/setup/setup_wizard/data/test_mfg.json +++ b/erpnext/setup/setup_wizard/data/test_mfg.json @@ -8,7 +8,7 @@ "currency": "INR", "customer_1": "Test Customer 1", "customer_2": "Test Customer 2", - "domain": "Manufacturing", + "domains": ["Manufacturing"], "email": "great@example.com", "full_name": "Great Tester", "fy_end_date": "2018-03-31", diff --git a/erpnext/setup/setup_wizard/sample_data.py b/erpnext/setup/setup_wizard/sample_data.py index 5a2fbd3ac58..c302841ec8b 100644 --- a/erpnext/setup/setup_wizard/sample_data.py +++ b/erpnext/setup/setup_wizard/sample_data.py @@ -10,7 +10,7 @@ import random, os, json from frappe import _ from markdown2 import markdown -def make_sample_data(domain, make_dependent = False): +def make_sample_data(domains, make_dependent = False): """Create a few opportunities, quotes, material requests, issues, todos, projects to help the user get started""" @@ -28,7 +28,7 @@ def make_sample_data(domain, make_dependent = False): if items and warehouses: make_material_request(frappe.get_all("Item")) - make_projects(domain) + make_projects(domains) import_email_alert() frappe.db.commit() @@ -89,7 +89,7 @@ def make_material_request(items): def make_issue(): pass -def make_projects(domain): +def make_projects(domains): current_date = frappe.utils.nowdate() project = frappe.get_doc({ "doctype": "Project", @@ -104,7 +104,7 @@ def make_projects(domain): "file": "explore.md" }] - if domain == 'Education': + if 'Education' in domains: tasks += [ { "title": _("Setup your Institute in ERPNext"), diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py index ec70c39c2f1..e861a96ee2e 100644 --- a/erpnext/setup/setup_wizard/setup_wizard.py +++ b/erpnext/setup/setup_wizard/setup_wizard.py @@ -39,8 +39,10 @@ def setup_complete(args=None): create_logo(args) frappe.local.message_log = [] + + domains = args.get('domains') domain_settings = frappe.get_single('Domain Settings') - domain_settings.set_active_domains([args.get('domain')]) + domain_settings.set_active_domains(domains) frappe.db.commit() login_as_first_user(args) @@ -49,7 +51,7 @@ def setup_complete(args=None): frappe.clear_cache() try: - make_sample_data(args.get('domain')) + make_sample_data(domains) frappe.clear_cache() except: # clear message @@ -80,7 +82,7 @@ def create_fiscal_year_and_company(args): 'country': args.get('country'), 'create_chart_of_accounts_based_on': 'Standard Template', 'chart_of_accounts': args.get('chart_of_accounts'), - 'domain': args.get('domain') + 'domain': args.get('domains')[0] }).insert() #Enable shopping cart diff --git a/erpnext/setup/setup_wizard/test_setup_wizard.py b/erpnext/setup/setup_wizard/test_setup_wizard.py index 5e2a3034f8b..a489133abae 100644 --- a/erpnext/setup/setup_wizard/test_setup_wizard.py +++ b/erpnext/setup/setup_wizard/test_setup_wizard.py @@ -40,8 +40,7 @@ def run_setup_wizard_test(): time.sleep(1) # domain slide - # time.sleep(3) - driver.set_select("domain", "Manufacturing") + driver.set_multicheck("domains", ["Manufacturing"]) time.sleep(1) driver.click(".next-btn") diff --git a/erpnext/utilities/user_progress.py b/erpnext/utilities/user_progress.py index e84377e1e8b..aa93c650e4f 100644 --- a/erpnext/utilities/user_progress.py +++ b/erpnext/utilities/user_progress.py @@ -272,10 +272,9 @@ def get_user_progress_slides(): slides = [] slide_settings = get_slide_settings() - domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') - + domains = frappe.get_active_domains() for s in slide_settings: - if not s.domains or (domain and domain in s.domains): + if not s.domains or any(d in domains for d in s.domains): s.mark_as_done_method = "erpnext.setup.doctype.setup_progress.setup_progress.set_action_completed_state" s.done = get_action_completed_state(s.action_name) or 0 slides.append(s)