[re-org] setup wizard in frappe
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 6b92117..74fcd58 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -41,6 +41,10 @@
web_include_js = "assets/js/erpnext-web.min.js"
web_include_css = "assets/erpnext/css/website.css"
+# setup wizard
+setup_wizard_requires = "assets/erpnext/js/setup_wizard.js"
+setup_wizard_complete = "erpnext.setup.setup_wizard.setup_wizard.setup_complete"
+
after_install = "erpnext.setup.install.after_install"
boot_session = "erpnext.startup.boot.boot_session"
@@ -150,6 +154,5 @@
</div>"""
get_translated_dict = {
- ("page", "setup-wizard"): "frappe.geo.country_info.get_translated_dict",
("doctype", "Global Defaults"): "frappe.geo.country_info.get_translated_dict"
}
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
new file mode 100644
index 0000000..e877737
--- /dev/null
+++ b/erpnext/public/js/setup_wizard.js
@@ -0,0 +1,415 @@
+frappe.provide("erpnext.wiz");
+
+frappe.pages['setup-wizard'].on_page_load = function(wrapper) {
+ if(sys_defaults.company) {
+ frappe.set_route("desk");
+ return;
+ }
+}
+
+$.extend(erpnext.wiz, {
+ region: {
+ title: __("Region"),
+ icon: "icon-flag",
+ help: __("Select your Country, Time Zone and Currency"),
+ fields: [
+ { fieldname: "country", label: __("Country"), reqd:1,
+ fieldtype: "Select" },
+ { fieldname: "timezone", label: __("Time Zone"), reqd:1,
+ fieldtype: "Select" },
+ { fieldname: "currency", label: __("Currency"), reqd:1,
+ fieldtype: "Select" },
+ ],
+
+ onload: function(slide) {
+ frappe.call({
+ method:"frappe.geo.country_info.get_country_timezone_info",
+ callback: function(data) {
+ erpnext.wiz.region.data = data.message;
+ erpnext.wiz.region.setup_fields(slide);
+ erpnext.wiz.region.bind_events(slide);
+ }
+ });
+ },
+ css_class: "single-column",
+ setup_fields: function(slide) {
+ var data = erpnext.wiz.region.data;
+
+ slide.get_input("country").empty()
+ .add_options([""].concat(keys(data.country_info).sort()));
+
+ slide.get_input("currency").empty()
+ .add_options(frappe.utils.unique([""].concat($.map(data.country_info,
+ function(opts, country) { return opts.currency; }))).sort());
+
+ slide.get_input("timezone").empty()
+ .add_options([""].concat(data.all_timezones));
+
+ if (data.default_country) {
+ slide.set_input("country", data.default_country);
+ }
+ },
+
+ bind_events: function(slide) {
+ slide.get_input("country").on("change", function() {
+ var country = slide.get_input("country").val();
+ var $timezone = slide.get_input("timezone");
+ var data = erpnext.wiz.region.data;
+
+ $timezone.empty();
+
+ // add country specific timezones first
+ if(country) {
+ var timezone_list = data.country_info[country].timezones || [];
+ $timezone.add_options(timezone_list.sort());
+ slide.get_field("currency").set_input(data.country_info[country].currency);
+ slide.get_field("currency").$input.trigger("change");
+ }
+
+ // add all timezones at the end, so that user has the option to change it to any timezone
+ $timezone.add_options([""].concat(data.all_timezones));
+
+ slide.get_field("timezone").set_input($timezone.val());
+
+ // temporarily set date format
+ frappe.boot.sysdefaults.date_format = (data.country_info[country].date_format
+ || "dd-mm-yyyy");
+ });
+
+ slide.get_input("currency").on("change", function() {
+ var currency = slide.get_input("currency").val();
+ if (!currency) return;
+ frappe.model.with_doc("Currency", currency, function() {
+ frappe.provide("locals.:Currency." + currency);
+ var currency_doc = frappe.model.get_doc("Currency", currency);
+ var number_format = currency_doc.number_format;
+ if (number_format==="#.###") {
+ number_format = "#.###,##";
+ } else if (number_format==="#,###") {
+ number_format = "#,###.##"
+ }
+
+ frappe.boot.sysdefaults.number_format = number_format;
+ locals[":Currency"][currency] = $.extend({}, currency_doc);
+ });
+ });
+ }
+ },
+
+ user: {
+ title: __("The First User: You"),
+ icon: "icon-user",
+ fields: [
+ {"fieldname": "first_name", "label": __("First Name"), "fieldtype": "Data",
+ reqd:1},
+ {"fieldname": "last_name", "label": __("Last Name"), "fieldtype": "Data"},
+ {"fieldname": "email", "label": __("Email Address"), "fieldtype": "Data",
+ reqd:1, "description": __("You will use it to Login"), "options":"Email"},
+ {"fieldname": "password", "label": __("Password"), "fieldtype": "Password",
+ reqd:1},
+ {fieldtype:"Attach Image", fieldname:"attach_user",
+ label: __("Attach Your Picture")},
+ ],
+ help: __('The first user will become the System Manager (you can change this later).'),
+ onload: function(slide) {
+ if(user!=="Administrator") {
+ slide.form.fields_dict.password.$wrapper.toggle(false);
+ slide.form.fields_dict.email.$wrapper.toggle(false);
+ slide.form.fields_dict.first_name.set_input(frappe.boot.user.first_name);
+ slide.form.fields_dict.last_name.set_input(frappe.boot.user.last_name);
+
+ var user_image = frappe.get_cookie("user_image");
+ if(user_image) {
+ var $attach_user = slide.form.fields_dict.attach_user.$wrapper;
+ $attach_user.find(".missing-image").toggle(false);
+ $attach_user.find("img").attr("src", decodeURIComponent(user_image)).toggle(true);
+ }
+
+ delete slide.form.fields_dict.email;
+ delete slide.form.fields_dict.password;
+ }
+ },
+ css_class: "single-column"
+ },
+
+ org: {
+ title: __("The Organization"),
+ icon: "icon-building",
+ fields: [
+ {fieldname:'company_name', label: __('Company Name'), fieldtype:'Data', reqd:1,
+ placeholder: __('e.g. "My Company LLC"')},
+ {fieldname:'company_abbr', label: __('Company Abbreviation'), fieldtype:'Data',
+ description: __('Max 5 characters'), placeholder: __('e.g. "MC"'), reqd:1},
+ {fieldname:'company_tagline', label: __('What does it do?'), fieldtype:'Data',
+ placeholder:__('e.g. "Build tools for builders"'), reqd:1},
+ {fieldname:'bank_account', label: __('Bank Account'), fieldtype:'Data',
+ placeholder: __('e.g. "XYZ National Bank"'), reqd:1 },
+ {fieldname:'chart_of_accounts', label: __('Chart of Accounts'),
+ options: "", fieldtype: 'Select'},
+
+ // TODO remove this
+ {fieldtype: "Section Break"},
+ {fieldname:'fy_start_date', label:__('Financial Year Start Date'), fieldtype:'Date',
+ description: __('Your financial year begins on'), reqd:1},
+ {fieldname:'fy_end_date', label:__('Financial Year End Date'), fieldtype:'Date',
+ description: __('Your financial year ends on'), reqd:1},
+ ],
+ help: __('The name of your company for which you are setting up this system.'),
+
+ onload: function(slide) {
+ erpnext.wiz.org.load_chart_of_accounts(slide);
+ erpnext.wiz.org.bind_events(slide);
+ erpnext.wiz.org.set_fy_dates(slide);
+ },
+
+ css_class: "single-column",
+
+ set_fy_dates: function(slide) {
+ var country = slide.wiz.get_values().country;
+
+ if(country) {
+ var fy = erpnext.wiz.fiscal_years[country];
+ var current_year = moment(new Date()).year();
+ var next_year = current_year + 1;
+ if(!fy) {
+ fy = ["01-01", "12-31"];
+ next_year = current_year;
+ }
+
+ slide.get_field("fy_start_date").set_input(current_year + "-" + fy[0]);
+ slide.get_field("fy_end_date").set_input(next_year + "-" + fy[1]);
+ }
+
+ },
+
+ load_chart_of_accounts: function(slide) {
+ var country = slide.wiz.get_values().country;
+
+ if(country) {
+ frappe.call({
+ method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.get_charts_for_country",
+ args: {"country": country},
+ callback: function(r) {
+ if(r.message) {
+ slide.get_input("chart_of_accounts").empty()
+ .add_options(r.message);
+
+ if (r.message.length===1) {
+ var field = slide.get_field("chart_of_accounts");
+ field.set_value(r.message[0]);
+ field.df.hidden = 1;
+ field.refresh();
+ }
+ }
+ }
+ })
+ }
+ },
+
+ bind_events: function(slide) {
+ slide.get_input("company_name").on("change", function() {
+ var parts = slide.get_input("company_name").val().split(" ");
+ var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join("");
+ slide.get_field("company_abbr").set_input(abbr.slice(0, 5).toUpperCase());
+ }).val(frappe.boot.sysdefaults.company_name || "").trigger("change");
+
+ slide.get_input("company_abbr").on("change", function() {
+ if(slide.get_input("company_abbr").val().length > 5) {
+ msgprint("Company Abbreviation cannot have more than 5 characters");
+ slide.get_field("company_abbr").set_input("");
+ }
+ });
+
+ // TODO remove this
+ slide.get_input("fy_start_date").on("change", function() {
+ var year_end_date =
+ frappe.datetime.add_days(frappe.datetime.add_months(
+ frappe.datetime.user_to_obj(slide.get_input("fy_start_date").val()), 12), -1);
+ slide.get_input("fy_end_date").val(frappe.datetime.obj_to_user(year_end_date));
+
+ });
+ }
+ },
+
+ branding: {
+ icon: "icon-bookmark",
+ title: __("The Brand"),
+ help: __('Upload your letter head and logo. (you can edit them later).'),
+ fields: [
+ {fieldtype:"Attach Image", fieldname:"attach_letterhead",
+ label: __("Attach Letterhead"),
+ description: __("Keep it web friendly 900px (w) by 100px (h)")
+ },
+ {fieldtype: "Column Break"},
+ {fieldtype:"Attach Image", fieldname:"attach_logo",
+ label:__("Attach Logo"),
+ description: __("100px by 100px")},
+ ],
+
+ css_class: "two-column"
+ },
+
+ users: {
+ icon: "icon-money",
+ "title": __("Add Users"),
+ "help": __("Add users to your organization, other than yourself"),
+ "fields": [],
+ before_load: function(slide) {
+ slide.fields = [];
+ for(var i=1; i<5; i++) {
+ slide.fields = slide.fields.concat([
+ {fieldtype:"Section Break"},
+ {fieldtype:"Data", fieldname:"user_fullname_"+ i,
+ label:__("Full Name")},
+ {fieldtype:"Data", fieldname:"user_email_" + i,
+ label:__("Email ID"), placeholder:__("user@example.com"),
+ options: "Email"},
+ {fieldtype:"Column Break"},
+ {fieldtype: "Check", fieldname: "user_sales_" + i,
+ label:__("Sales"), default: 1},
+ {fieldtype: "Check", fieldname: "user_purchaser_" + i,
+ label:__("Purchaser"), default: 1},
+ {fieldtype: "Check", fieldname: "user_accountant_" + i,
+ label:__("Accountant"), default: 1},
+ ]);
+ }
+ },
+ css_class: "two-column"
+ },
+
+ taxes: {
+ icon: "icon-money",
+ "title": __("Add Taxes"),
+ "help": __("List your tax heads (e.g. VAT, Customs etc; they should have unique names) and their standard rates. This will create a standard template, which you can edit and add more later."),
+ "fields": [],
+ before_load: function(slide) {
+ slide.fields = [];
+ for(var i=1; i<4; i++) {
+ slide.fields = slide.fields.concat([
+ {fieldtype:"Section Break"},
+ {fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i,
+ placeholder:__("e.g. VAT") + " " + i},
+ {fieldtype:"Column Break"},
+ {fieldtype:"Float", fieldname:"tax_rate_" + i, label:__("Rate (%)"), placeholder:__("e.g. 5")},
+ ]);
+ }
+ },
+ css_class: "two-column"
+ },
+
+ customers: {
+ icon: "icon-group",
+ "title": __("Your Customers"),
+ "help": __("List a few of your customers. They could be organizations or individuals."),
+ "fields": [],
+ before_load: function(slide) {
+ slide.fields = [];
+ for(var i=1; i<6; i++) {
+ slide.fields = slide.fields.concat([
+ {fieldtype:"Section Break"},
+ {fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i,
+ placeholder:__("Customer Name")},
+ {fieldtype:"Column Break"},
+ {fieldtype:"Data", fieldname:"customer_contact_" + i,
+ label:__("Contact Name") + " " + i, placeholder:__("Contact Name")}
+ ])
+ }
+ slide.fields[1].reqd = 1;
+ },
+ css_class: "two-column"
+ },
+
+ suppliers: {
+ icon: "icon-group",
+ "title": __("Your Suppliers"),
+ "help": __("List a few of your suppliers. They could be organizations or individuals."),
+ "fields": [],
+ before_load: function(slide) {
+ slide.fields = [];
+ for(var i=1; i<6; i++) {
+ slide.fields = slide.fields.concat([
+ {fieldtype:"Section Break"},
+ {fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i,
+ placeholder:__("Supplier Name")},
+ {fieldtype:"Column Break"},
+ {fieldtype:"Data", fieldname:"supplier_contact_" + i,
+ label:__("Contact Name") + " " + i, placeholder:__("Contact Name")},
+ ])
+ }
+ slide.fields[1].reqd = 1;
+ },
+ css_class: "two-column"
+ },
+
+ items: {
+ icon: "icon-barcode",
+ "title": __("Your Products or Services"),
+ "help": __("List your products or services that you buy or sell. Make sure to check the Item Group, Unit of Measure and other properties when you start."),
+ "fields": [],
+ before_load: function(slide) {
+ slide.fields = [];
+ for(var i=1; i<6; i++) {
+ slide.fields = slide.fields.concat([
+ {fieldtype:"Section Break", show_section_border: true},
+ {fieldtype:"Data", fieldname:"item_" + i, label:__("Item") + " " + i,
+ placeholder:__("A Product or Service")},
+ {fieldtype:"Select", label:__("Group"), fieldname:"item_group_" + i,
+ options:[__("Products"), __("Services"),
+ __("Raw Material"), __("Consumable"), __("Sub Assemblies")],
+ "default": __("Products")},
+ {fieldtype:"Select", fieldname:"item_uom_" + i, label:__("UOM"),
+ options:[__("Unit"), __("Nos"), __("Box"), __("Pair"), __("Kg"), __("Set"),
+ __("Hour"), __("Minute")],
+ "default": __("Unit")},
+ {fieldtype: "Check", fieldname: "is_sales_item_" + i, label:__("We sell this Item"), default: 1},
+ {fieldtype: "Check", fieldname: "is_purchase_item_" + i, label:__("We buy this Item")},
+ {fieldtype:"Column Break"},
+ {fieldtype:"Currency", fieldname:"item_price_" + i, label:__("Rate")},
+ {fieldtype:"Attach Image", fieldname:"item_img_" + i, label:__("Attach Image")},
+ ])
+ }
+ slide.fields[1].reqd = 1;
+
+ // dummy data
+ slide.fields.push({fieldtype: "Section Break"});
+ slide.fields.push({fieldtype: "Check", fieldname: "add_sample_data",
+ label: __("Add a few sample records"), "default": 1});
+ },
+ css_class: "two-column"
+ },
+});
+
+// Source: https://en.wikipedia.org/wiki/Fiscal_year
+// default 1st Jan - 31st Dec
+
+erpnext.wiz.fiscal_years = {
+ "Afghanistan": ["12-20", "12-21"],
+ "Australia": ["07-01", "06-30"],
+ "Bangladesh": ["07-01", "06-30"],
+ "Canada": ["04-01", "03-31"],
+ "Costa Rica": ["10-01", "09-30"],
+ "Egypt": ["07-01", "06-30"],
+ "Hong Kong": ["04-01", "03-31"],
+ "India": ["04-01", "03-31"],
+ "Iran": ["06-23", "06-22"],
+ "Italy": ["07-01", "06-30"],
+ "Myanmar": ["04-01", "03-31"],
+ "New Zealand": ["04-01", "03-31"],
+ "Pakistan": ["07-01", "06-30"],
+ "Singapore": ["04-01", "03-31"],
+ "South Africa": ["03-01", "02-28"],
+ "Thailand": ["10-01", "09-30"],
+ "United Kingdom": ["04-01", "03-31"],
+}
+
+frappe.wiz.on("before_load", function() {
+ frappe.wiz.add_slide(erpnext.wiz.user);
+ frappe.wiz.add_slide(erpnext.wiz.org);
+ frappe.wiz.add_slide(erpnext.wiz.branding);
+ frappe.wiz.add_slide(erpnext.wiz.users);
+ frappe.wiz.add_slide(erpnext.wiz.taxes);
+ frappe.wiz.add_slide(erpnext.wiz.customers);
+ frappe.wiz.add_slide(erpnext.wiz.suppliers);
+ frappe.wiz.add_slide(erpnext.wiz.items);
+ frappe.wiz.welcome_page = "#welcome-to-erpnext";
+});
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index a1bcc16..dcb6eb3 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -11,9 +11,8 @@
def after_install():
frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
set_single_defaults()
- frappe.db.set_default('desktop:home_page', 'setup-wizard');
feature_setup()
- from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to
+ from erpnext.setup.setup_wizard.setup_wizard import add_all_roles_to
add_all_roles_to("Administrator")
add_web_forms()
frappe.db.commit()
diff --git a/erpnext/setup/page/setup_wizard/fixtures/__init__.py b/erpnext/setup/page/setup_wizard/fixtures/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/setup/page/setup_wizard/fixtures/__init__.py
+++ /dev/null
diff --git a/erpnext/setup/page/setup_wizard/fixtures/operations.py b/erpnext/setup/page/setup_wizard/fixtures/operations.py
deleted file mode 100644
index cbb3071..0000000
--- a/erpnext/setup/page/setup_wizard/fixtures/operations.py
+++ /dev/null
@@ -1,167 +0,0 @@
-# source: http://en.wikipedia.org/wiki/List_of_manufacturing_processes"
-
-from __future__ import unicode_literals
-from frappe import _
-
-def get_operations():
- return [
- _("Centrifugal casting"),
- _("Continuous casting"),
- _("Die casting"),
- _("Evaporative-pattern casting"),
- _("Full-mold casting"),
- _("Lost-foam casting"),
- _("Investment casting"),
- _("Countergravity casting"),
- _("Permanent mold casting"),
- _("Resin casting"),
- _("Sand casting"),
- _("Shell molding"),
- _("Spray forming"),
- _("Vacuum molding"),
- _("Molding"),
- _("Compaction plus sintering"),
- _("Hot isostatic pressing"),
- _("Metal injection molding"),
- _("Injection molding"),
- _("Compression molding"),
- _("Blow molding"),
- _("Dip molding"),
- _("Rotational molding"),
- _("Thermoforming"),
- _("Laminating"),
- _("Shrink fitting"),
- _("Shrink wrapping"),
- _("End tube forming"),
- _("Tube beading"),
- _("Forging"),
- _("Rolling"),
- _("Cold rolling"),
- _("Hot rolling"),
- _("Cryorolling"),
- _("Cross-rolling"),
- _("Pressing"),
- _("Embossing"),
- _("Stretch forming"),
- _("Blanking"),
- _("Drawing"),
- _("Bulging"),
- _("Necking"),
- _("Nosing"),
- _("Deep drawing"),
- _("Bending"),
- _("Hemming"),
- _("Shearing"),
- _("Piercing"),
- _("Trimming"),
- _("Shaving"),
- _("Notching"),
- _("Perforating"),
- _("Nibbling"),
- _("Lancing"),
- _("Cutting"),
- _("Stamping"),
- _("Coining"),
- _("Straight shearing"),
- _("Slitting"),
- _("Redrawing"),
- _("Ironing"),
- _("Flattening"),
- _("Swaging"),
- _("Spinning"),
- _("Peening"),
- _("Explosive forming"),
- _("Electroforming"),
- _("Staking"),
- _("Seaming"),
- _("Flanging"),
- _("Straightening"),
- _("Decambering"),
- _("Cold sizing"),
- _("Hubbing"),
- _("Hot metal gas forming"),
- _("Curling"),
- _("Hydroforming"),
- _("Machining"),
- _("Milling"),
- _("Hammering"),
- _("Smelting"),
- _("Refining"),
- _("Annealing"),
- _("Pickling"),
- _("Coating"),
- _("Turning"),
- _("Facing"),
- _("Boring"),
- _("Knurling"),
- _("Hard turning"),
- _("Drilling"),
- _("Reaming"),
- _("Countersinking"),
- _("Tapping"),
- _("Sawing"),
- _("Filing"),
- _("Broaching"),
- _("Shaping"),
- _("Planing"),
- _("Double housing"),
- _("Abrasive jet machining"),
- _("Water jet cutting"),
- _("Photochemical machining"),
- _("Honing"),
- _("Electro-chemical grinding"),
- _("Finishing & industrial finishing"),
- _("Abrasive blasting"),
- _("Buffing"),
- _("Burnishing"),
- _("Electroplating"),
- _("Electropolishing"),
- _("Magnetic field-assisted finishing"),
- _("Etching"),
- _("Linishing"),
- _("Mass finishing"),
- _("Tumbling"),
- _("Spindle finishing"),
- _("Vibratory finishing"),
- _("Plating"),
- _("Polishing"),
- _("Superfinishing"),
- _("Wire brushing"),
- _("Routing"),
- _("Hobbing"),
- _("Ultrasonic machining"),
- _("Electron beam machining"),
- _("Electrochemical machining"),
- _("Laser cutting"),
- _("Laser drilling"),
- _("Grinding"),
- _("Gashing"),
- _("Biomachining"),
- _("Joining"),
- _("Welding"),
- _("Brazing"),
- _("Sintering"),
- _("Adhesive bonding"),
- _("Nailing"),
- _("Screwing"),
- _("Riveting"),
- _("Clinching"),
- _("Pinning"),
- _("Stitching"),
- _("Stapling"),
- _("Press fitting"),
- _("3D printing"),
- _("Direct metal laser sintering"),
- _("Fused deposition modeling"),
- _("Laminated object manufacturing"),
- _("Laser engineered net shaping"),
- _("Selective laser sintering"),
- _("Mining"),
- _("Quarrying"),
- _("Blasting"),
- _("Woodworking"),
- _("Lapping"),
- _("Morticing"),
- _("Crushing"),
- _("Packaging and labeling")
- ]
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.css b/erpnext/setup/page/setup_wizard/setup_wizard.css
deleted file mode 100644
index 41eef34..0000000
--- a/erpnext/setup/page/setup_wizard/setup_wizard.css
+++ /dev/null
@@ -1,70 +0,0 @@
-.setup-wizard-slide {
- padding-left: 0px;
- padding-right: 0px;
-}
-
-@media (min-width: 768px) {
- .setup-wizard-slide.single-column {
- max-width: 500px;
- }
-
- .setup-wizard-slide.two-column {
- max-width: 768px;
- }
-}
-
-.setup-wizard-slide .lead {
- margin-bottom: 10px;
-}
-
-.setup-wizard-slide .form {
- margin-top: 20px;
- border: 1px solid #d1d8dd;
- box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.1);
-}
-
-.setup-wizard-slide .footer {
- margin: 20px auto;
-}
-
-.setup-wizard-progress {
- border-bottom: 1px solid #d1d8dd;
- padding-bottom: 15px;
- margin: -20px auto 20px;
-}
-
-.setup-wizard-slide .icon-fixed-width {
- vertical-align: middle;
-}
-
-.setup-wizard-slide .icon-circle-blank {
- font-size: 7px;
-}
-
-.setup-wizard-slide .icon-circle {
- font-size: 10px;
-}
-
-.setup-wizard-slide .frappe-control[data-fieldtype="Attach Image"] {
- text-align: center;
-}
-
-.setup-wizard-slide .missing-image,
-.setup-wizard-slide .attach-image-display {
- display: block;
- position: relative;
- left: 50%;
- transform: translate(-50%, 0);
- -webkit-transform: translate(-50%, 0);
-}
-
-.setup-wizard-slide .missing-image .octicon {
- position: relative;
- top: 50%;
- transform: translate(0px, -50%);
- -webkit-transform: translate(0px, -50%);
-}
-
-.setup-wizard-message-image {
- margin: 15px auto;
-}
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js
deleted file mode 100644
index 998131f..0000000
--- a/erpnext/setup/page/setup_wizard/setup_wizard.js
+++ /dev/null
@@ -1,710 +0,0 @@
-frappe.provide("erpnext.wiz");
-
-frappe.pages['setup-wizard'].on_page_load = function(wrapper) {
- if(sys_defaults.company) {
- frappe.set_route("desk-home");
- return;
- }
- $(".navbar:first").toggle(false);
- $("body").css({"padding-top":"30px"});
-
- frappe.require("/assets/frappe/css/animate.min.css");
-
- var wizard_settings = {
- page_name: "setup-wizard",
- parent: wrapper,
- on_complete: function(wiz) {
- erpnext.wiz.setup_account(wiz);
- },
- title: __("Welcome"),
- working_html: erpnext.wiz.working_html,
- complete_html: erpnext.wiz.complete_html,
- slides: [
- erpnext.wiz.welcome.slide,
- erpnext.wiz.region.slide,
- erpnext.wiz.user.slide,
- erpnext.wiz.org.slide,
- erpnext.wiz.branding.slide,
- erpnext.wiz.users.slide,
- erpnext.wiz.taxes.slide,
- erpnext.wiz.customers.slide,
- erpnext.wiz.suppliers.slide,
- erpnext.wiz.items.slide
- ]
- }
-
-
- erpnext.wiz.wizard = new erpnext.wiz.Wizard(wizard_settings)
-}
-
-frappe.pages['setup-wizard'].on_page_show = function(wrapper) {
- if(frappe.get_route()[1]) {
- erpnext.wiz.wizard.show(frappe.get_route()[1]);
- }
-
-}
-
-erpnext.wiz.Wizard = Class.extend({
- init: function(opts) {
- $.extend(this, opts);
- this.make();
- this.slides = this.slides;
- this.slide_dict = {};
- this.welcomed = true;
- frappe.set_route("setup-wizard/0");
- },
- make: function() {
- this.parent = $('<div class="setup-wizard-wrapper">').appendTo(this.parent);
- },
- get_message: function(html) {
- return $(repl('<div data-state="setup-complete">\
- <div style="padding: 40px;" class="text-center">%(html)s</div>\
- </div>', {html:html}))
- },
- show_working: function() {
- this.hide_current_slide();
- frappe.set_route(this.page_name);
- this.current_slide = {"$wrapper": this.get_message(this.working_html()).appendTo(this.parent)};
- },
- show_complete: function() {
- this.hide_current_slide();
- this.current_slide = {"$wrapper": this.get_message(this.complete_html()).appendTo(this.parent)};
- },
- show: function(id) {
- if(!this.welcomed) {
- frappe.set_route(this.page_name);
- return;
- }
- id = cint(id);
- if(this.current_slide && this.current_slide.id===id)
- return;
- if(!this.slide_dict[id]) {
- this.slide_dict[id] = new erpnext.wiz.WizardSlide($.extend(this.slides[id], {wiz:this, id:id}));
- this.slide_dict[id].make();
- }
-
- this.hide_current_slide();
-
- this.current_slide = this.slide_dict[id];
- this.current_slide.$wrapper.removeClass("hidden");
- },
- hide_current_slide: function() {
- if(this.current_slide) {
- this.current_slide.$wrapper.addClass("hidden");
- this.current_slide = null;
- }
- },
- get_values: function() {
- var values = {};
- $.each(this.slide_dict, function(id, slide) {
- $.extend(values, slide.values)
- })
- return values;
- }
-});
-
-erpnext.wiz.WizardSlide = Class.extend({
- init: function(opts) {
- $.extend(this, opts);
- this.$wrapper = $('<div class="slide-wrapper hidden"></div>')
- .appendTo(this.wiz.parent)
- .attr("data-slide-id", this.id);
- },
- make: function() {
- var me = this;
- if(this.$body) this.$body.remove();
-
- if(this.before_load) {
- this.before_load(this);
- }
-
- this.$body = $(frappe.render_template("setup_wizard_page", {
- help: __(this.help),
- title:__(this.title),
- main_title:__(this.wiz.title),
- step: this.id + 1,
- name: this.name,
- css_class: this.css_class || "",
- slides_count: this.wiz.slides.length
- })).appendTo(this.$wrapper);
-
- this.body = this.$body.find(".form")[0];
-
- if(this.fields) {
- this.form = new frappe.ui.FieldGroup({
- fields: this.fields,
- body: this.body,
- no_submit_on_enter: true
- });
- this.form.make();
- } else {
- $(this.body).html(this.html);
- }
-
- if(this.id > 0) {
- this.$prev = this.$body.find('.prev-btn').removeClass("hide")
- .click(function() {
- frappe.set_route(me.wiz.page_name, me.id-1 + "");
- })
- .css({"margin-right": "10px"});
- }
- if(this.id+1 < this.wiz.slides.length) {
- this.$next = this.$body.find('.next-btn').removeClass("hide")
- .click(function() {
- me.values = me.form.get_values();
- if(me.values===null)
- return;
- if(me.validate && !me.validate())
- return;
- frappe.set_route(me.wiz.page_name, me.id+1 + "");
- })
- } else {
- this.$complete = this.$body.find('.complete-btn').removeClass("hide")
- .click(function() {
- me.values = me.form.get_values();
- if(me.values===null)
- return;
- if(me.validate && !me.validate())
- return;
- me.wiz.on_complete(me.wiz);
- })
- }
-
- if(this.onload) {
- this.onload(this);
- }
-
- },
- get_input: function(fn) {
- return this.form.get_input(fn);
- },
- get_field: function(fn) {
- return this.form.get_field(fn);
- }
-});
-
-$.extend(erpnext.wiz, {
- welcome: {
- slide: {
- name: "welcome",
- title: __("Welcome to ERPNext"),
- icon: "icon-world",
- help: __("Let's prepare the system for first use."),
-
- fields: [
- { fieldname: "language", label: __("Select Your Language"), reqd:1,
- fieldtype: "Select" },
- ],
-
- onload: function(slide) {
- if (!erpnext.wiz.welcome.data) {
- erpnext.wiz.welcome.load_languages(slide);
- } else {
- erpnext.wiz.welcome.setup_fields(slide);
- }
- },
-
- css_class: "single-column"
- },
-
- load_languages: function(slide) {
- frappe.call({
- method: "erpnext.setup.page.setup_wizard.setup_wizard.load_languages",
- callback: function(r) {
- erpnext.wiz.welcome.data = r.message;
- erpnext.wiz.welcome.setup_fields(slide);
-
- slide.get_field("language")
- .set_input(erpnext.wiz.welcome.data.default_language || "english");
- moment.locale("en");
- }
- });
- },
-
- setup_fields: function(slide) {
- var select = slide.get_field("language");
- select.df.options = erpnext.wiz.welcome.data.languages;
- select.refresh();
- erpnext.wiz.welcome.bind_events(slide);
- },
-
- bind_events: function(slide) {
- slide.get_input("language").unbind("change").on("change", function() {
- var lang = $(this).val() || "english";
- frappe._messages = {};
- frappe.call({
- method: "erpnext.setup.page.setup_wizard.setup_wizard.load_messages",
- args: {
- language: lang
- },
- callback: function(r) {
- // TODO save values!
-
- // re-render all slides
- $.each(slide.wiz.slide_dict, function(key, s) {
- s.make();
- });
-
- // select is re-made after language change
- var select = slide.get_field("language");
- select.set_input(lang);
- }
- })
- });
- },
- },
-
- region: {
- slide: {
- title: __("Region"),
- icon: "icon-flag",
- help: __("Select your Country, Time Zone and Currency"),
- fields: [
- { fieldname: "country", label: __("Country"), reqd:1,
- fieldtype: "Select" },
- { fieldname: "timezone", label: __("Time Zone"), reqd:1,
- fieldtype: "Select" },
- { fieldname: "currency", label: __("Currency"), reqd:1,
- fieldtype: "Select" },
- ],
-
- onload: function(slide) {
- frappe.call({
- method:"frappe.geo.country_info.get_country_timezone_info",
- callback: function(data) {
- erpnext.wiz.region.data = data.message;
- erpnext.wiz.region.setup_fields(slide);
- erpnext.wiz.region.bind_events(slide);
- }
- });
- },
-
- css_class: "single-column"
- },
-
- setup_fields: function(slide) {
- var data = erpnext.wiz.region.data;
-
- slide.get_input("country").empty()
- .add_options([""].concat(keys(data.country_info).sort()));
-
- slide.get_input("currency").empty()
- .add_options(frappe.utils.unique([""].concat($.map(data.country_info,
- function(opts, country) { return opts.currency; }))).sort());
-
- slide.get_input("timezone").empty()
- .add_options([""].concat(data.all_timezones));
-
- if (data.default_country) {
- slide.set_input("country", data.default_country);
- }
- },
-
- bind_events: function(slide) {
- slide.get_input("country").on("change", function() {
- var country = slide.get_input("country").val();
- var $timezone = slide.get_input("timezone");
- var data = erpnext.wiz.region.data;
-
- $timezone.empty();
-
- // add country specific timezones first
- if(country) {
- var timezone_list = data.country_info[country].timezones || [];
- $timezone.add_options(timezone_list.sort());
- slide.get_field("currency").set_input(data.country_info[country].currency);
- slide.get_field("currency").$input.trigger("change");
- }
-
- // add all timezones at the end, so that user has the option to change it to any timezone
- $timezone.add_options([""].concat(data.all_timezones));
-
- slide.get_field("timezone").set_input($timezone.val());
-
- // temporarily set date format
- frappe.boot.sysdefaults.date_format = (data.country_info[country].date_format
- || "dd-mm-yyyy");
- });
-
- slide.get_input("currency").on("change", function() {
- var currency = slide.get_input("currency").val();
- if (!currency) return;
- frappe.model.with_doc("Currency", currency, function() {
- frappe.provide("locals.:Currency." + currency);
- var currency_doc = frappe.model.get_doc("Currency", currency);
- var number_format = currency_doc.number_format;
- if (number_format==="#.###") {
- number_format = "#.###,##";
- } else if (number_format==="#,###") {
- number_format = "#,###.##"
- }
-
- frappe.boot.sysdefaults.number_format = number_format;
- locals[":Currency"][currency] = $.extend({}, currency_doc);
- });
- });
- }
- },
-
- user: {
- slide: {
- title: __("The First User: You"),
- icon: "icon-user",
- fields: [
- {"fieldname": "first_name", "label": __("First Name"), "fieldtype": "Data",
- reqd:1},
- {"fieldname": "last_name", "label": __("Last Name"), "fieldtype": "Data"},
- {"fieldname": "email", "label": __("Email Address"), "fieldtype": "Data",
- reqd:1, "description": __("You will use it to Login"), "options":"Email"},
- {"fieldname": "password", "label": __("Password"), "fieldtype": "Password",
- reqd:1},
- {fieldtype:"Attach Image", fieldname:"attach_user",
- label: __("Attach Your Picture")},
- ],
- help: __('The first user will become the System Manager (you can change this later).'),
- onload: function(slide) {
- if(user!=="Administrator") {
- slide.form.fields_dict.password.$wrapper.toggle(false);
- slide.form.fields_dict.email.$wrapper.toggle(false);
- slide.form.fields_dict.first_name.set_input(frappe.boot.user.first_name);
- slide.form.fields_dict.last_name.set_input(frappe.boot.user.last_name);
-
- var user_image = frappe.get_cookie("user_image");
- if(user_image) {
- var $attach_user = slide.form.fields_dict.attach_user.$wrapper;
- $attach_user.find(".missing-image").toggle(false);
- $attach_user.find("img").attr("src", decodeURIComponent(user_image)).toggle(true);
- }
-
- delete slide.form.fields_dict.email;
- delete slide.form.fields_dict.password;
- }
- },
- css_class: "single-column"
- },
- },
-
- org: {
- slide: {
- title: __("The Organization"),
- icon: "icon-building",
- fields: [
- {fieldname:'company_name', label: __('Company Name'), fieldtype:'Data', reqd:1,
- placeholder: __('e.g. "My Company LLC"')},
- {fieldname:'company_abbr', label: __('Company Abbreviation'), fieldtype:'Data',
- description: __('Max 5 characters'), placeholder: __('e.g. "MC"'), reqd:1},
- {fieldname:'company_tagline', label: __('What does it do?'), fieldtype:'Data',
- placeholder:__('e.g. "Build tools for builders"'), reqd:1},
- {fieldname:'bank_account', label: __('Bank Account'), fieldtype:'Data',
- placeholder: __('e.g. "XYZ National Bank"'), reqd:1 },
- {fieldname:'chart_of_accounts', label: __('Chart of Accounts'),
- options: "", fieldtype: 'Select'},
-
- // TODO remove this
- {fieldtype: "Section Break"},
- {fieldname:'fy_start_date', label:__('Financial Year Start Date'), fieldtype:'Date',
- description: __('Your financial year begins on'), reqd:1},
- {fieldname:'fy_end_date', label:__('Financial Year End Date'), fieldtype:'Date',
- description: __('Your financial year ends on'), reqd:1},
- ],
- help: __('The name of your company for which you are setting up this system.'),
-
- onload: function(slide) {
- erpnext.wiz.org.load_chart_of_accounts(slide);
- erpnext.wiz.org.bind_events(slide);
- erpnext.wiz.org.set_fy_dates(slide);
- },
-
- css_class: "single-column"
- },
-
- set_fy_dates: function(slide) {
- var country = slide.wiz.get_values().country;
-
- if(country) {
- var fy = erpnext.wiz.fiscal_years[country];
- var current_year = moment(new Date()).year();
- var next_year = current_year + 1;
- if(!fy) {
- fy = ["01-01", "12-31"];
- next_year = current_year;
- }
-
- slide.get_field("fy_start_date").set_input(current_year + "-" + fy[0]);
- slide.get_field("fy_end_date").set_input(next_year + "-" + fy[1]);
- }
-
- },
-
- load_chart_of_accounts: function(slide) {
- var country = slide.wiz.get_values().country;
-
- if(country) {
- frappe.call({
- method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.get_charts_for_country",
- args: {"country": country},
- callback: function(r) {
- if(r.message) {
- slide.get_input("chart_of_accounts").empty()
- .add_options(r.message);
-
- if (r.message.length===1) {
- var field = slide.get_field("chart_of_accounts");
- field.set_value(r.message[0]);
- field.df.hidden = 1;
- field.refresh();
- }
- }
- }
- })
- }
- },
-
- bind_events: function(slide) {
- slide.get_input("company_name").on("change", function() {
- var parts = slide.get_input("company_name").val().split(" ");
- var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join("");
- slide.get_field("company_abbr").set_input(abbr.slice(0, 5).toUpperCase());
- }).val(frappe.boot.sysdefaults.company_name || "").trigger("change");
-
- slide.get_input("company_abbr").on("change", function() {
- if(slide.get_input("company_abbr").val().length > 5) {
- msgprint("Company Abbreviation cannot have more than 5 characters");
- slide.get_field("company_abbr").set_input("");
- }
- });
-
- // TODO remove this
- slide.get_input("fy_start_date").on("change", function() {
- var year_end_date =
- frappe.datetime.add_days(frappe.datetime.add_months(
- frappe.datetime.user_to_obj(slide.get_input("fy_start_date").val()), 12), -1);
- slide.get_input("fy_end_date").val(frappe.datetime.obj_to_user(year_end_date));
-
- });
- }
- },
-
- branding: {
- slide: {
- icon: "icon-bookmark",
- title: __("The Brand"),
- help: __('Upload your letter head and logo. (you can edit them later).'),
- fields: [
- {fieldtype:"Attach Image", fieldname:"attach_letterhead",
- label: __("Attach Letterhead"),
- description: __("Keep it web friendly 900px (w) by 100px (h)")
- },
- {fieldtype: "Column Break"},
- {fieldtype:"Attach Image", fieldname:"attach_logo",
- label:__("Attach Logo"),
- description: __("100px by 100px")},
- ],
-
- css_class: "two-column"
- },
- },
-
- users: {
- slide: {
- icon: "icon-money",
- "title": __("Add Users"),
- "help": __("Add users to your organization, other than yourself"),
- "fields": [],
- before_load: function(slide) {
- slide.fields = [];
- for(var i=1; i<5; i++) {
- slide.fields = slide.fields.concat([
- {fieldtype:"Section Break"},
- {fieldtype:"Data", fieldname:"user_fullname_"+ i,
- label:__("Full Name")},
- {fieldtype:"Data", fieldname:"user_email_" + i,
- label:__("Email ID"), placeholder:__("user@example.com"),
- options: "Email"},
- {fieldtype:"Column Break"},
- {fieldtype: "Check", fieldname: "user_sales_" + i,
- label:__("Sales"), default: 1},
- {fieldtype: "Check", fieldname: "user_purchaser_" + i,
- label:__("Purchaser"), default: 1},
- {fieldtype: "Check", fieldname: "user_accountant_" + i,
- label:__("Accountant"), default: 1},
- ]);
- }
- },
- css_class: "two-column"
- },
- },
-
- taxes: {
- slide: {
- icon: "icon-money",
- "title": __("Add Taxes"),
- "help": __("List your tax heads (e.g. VAT, Customs etc; they should have unique names) and their standard rates. This will create a standard template, which you can edit and add more later."),
- "fields": [],
- before_load: function(slide) {
- slide.fields = [];
- for(var i=1; i<4; i++) {
- slide.fields = slide.fields.concat([
- {fieldtype:"Section Break"},
- {fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i,
- placeholder:__("e.g. VAT") + " " + i},
- {fieldtype:"Column Break"},
- {fieldtype:"Float", fieldname:"tax_rate_" + i, label:__("Rate (%)"), placeholder:__("e.g. 5")},
- ]);
- }
- },
- css_class: "two-column"
- },
- },
-
- customers: {
- slide: {
- icon: "icon-group",
- "title": __("Your Customers"),
- "help": __("List a few of your customers. They could be organizations or individuals."),
- "fields": [],
- before_load: function(slide) {
- slide.fields = [];
- for(var i=1; i<6; i++) {
- slide.fields = slide.fields.concat([
- {fieldtype:"Section Break"},
- {fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i,
- placeholder:__("Customer Name")},
- {fieldtype:"Column Break"},
- {fieldtype:"Data", fieldname:"customer_contact_" + i,
- label:__("Contact Name") + " " + i, placeholder:__("Contact Name")}
- ])
- }
- slide.fields[1].reqd = 1;
- },
- css_class: "two-column"
- },
- },
-
- suppliers: {
- slide: {
- icon: "icon-group",
- "title": __("Your Suppliers"),
- "help": __("List a few of your suppliers. They could be organizations or individuals."),
- "fields": [],
- before_load: function(slide) {
- slide.fields = [];
- for(var i=1; i<6; i++) {
- slide.fields = slide.fields.concat([
- {fieldtype:"Section Break"},
- {fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i,
- placeholder:__("Supplier Name")},
- {fieldtype:"Column Break"},
- {fieldtype:"Data", fieldname:"supplier_contact_" + i,
- label:__("Contact Name") + " " + i, placeholder:__("Contact Name")},
- ])
- }
- slide.fields[1].reqd = 1;
- },
- css_class: "two-column"
- },
- },
-
- items: {
- slide: {
- icon: "icon-barcode",
- "title": __("Your Products or Services"),
- "help": __("List your products or services that you buy or sell. Make sure to check the Item Group, Unit of Measure and other properties when you start."),
- "fields": [],
- before_load: function(slide) {
- slide.fields = [];
- for(var i=1; i<6; i++) {
- slide.fields = slide.fields.concat([
- {fieldtype:"Section Break", show_section_border: true},
- {fieldtype:"Data", fieldname:"item_" + i, label:__("Item") + " " + i,
- placeholder:__("A Product or Service")},
- {fieldtype:"Select", label:__("Group"), fieldname:"item_group_" + i,
- options:[__("Products"), __("Services"),
- __("Raw Material"), __("Consumable"), __("Sub Assemblies")],
- "default": __("Products")},
- {fieldtype:"Select", fieldname:"item_uom_" + i, label:__("UOM"),
- options:[__("Unit"), __("Nos"), __("Box"), __("Pair"), __("Kg"), __("Set"),
- __("Hour"), __("Minute")],
- "default": __("Unit")},
- {fieldtype: "Check", fieldname: "is_sales_item_" + i, label:__("We sell this Item"), default: 1},
- {fieldtype: "Check", fieldname: "is_purchase_item_" + i, label:__("We buy this Item")},
- {fieldtype:"Column Break"},
- {fieldtype:"Currency", fieldname:"item_price_" + i, label:__("Rate")},
- {fieldtype:"Attach Image", fieldname:"item_img_" + i, label:__("Attach Image")},
- ])
- }
- slide.fields[1].reqd = 1;
-
- // dummy data
- slide.fields.push({fieldtype: "Section Break"});
- slide.fields.push({fieldtype: "Check", fieldname: "add_sample_data",
- label: __("Add a few sample records"), "default": 1});
- },
- css_class: "two-column"
- },
- },
-
- working_html: function() {
- var msg = $(frappe.render_template("setup_wizard_message", {
- image: "/assets/frappe/images/ui/bubble-tea-smile.svg",
- title: __("Setting Up"),
- message: __('Sit tight while your system is being setup. This may take a few moments.')
- }));
- msg.find(".setup-wizard-message-image").addClass("animated infinite bounce");
- return msg.html();
- },
-
- complete_html: function() {
- return frappe.render_template("setup_wizard_message", {
- image: "/assets/frappe/images/ui/bubble-tea-happy.svg",
- title: __('Setup Complete'),
- message: ""
- });
- },
-
- setup_account: function(wiz) {
- var values = wiz.get_values();
- wiz.show_working();
- return frappe.call({
- method: "erpnext.setup.page.setup_wizard.setup_wizard.setup_account",
- args: values,
- callback: function(r) {
- wiz.show_complete();
- localStorage.setItem("session_last_route", "#welcome-to-erpnext");
- setTimeout(function() {
- window.location = "/desk";
- }, 2000);
- },
- error: function(r) {
-
- var d = msgprint(__("There were errors."));
- d.custom_onhide = function() {
- frappe.set_route(erpnext.wiz.wizard.page_name, erpnext.wiz.wizard.slides.length - 1);
- };
- }
- });
- },
-});
-
-// Source: https://en.wikipedia.org/wiki/Fiscal_year
-// default 1st Jan - 31st Dec
-
-erpnext.wiz.fiscal_years = {
- "Afghanistan": ["12-20", "12-21"],
- "Australia": ["07-01", "06-30"],
- "Bangladesh": ["07-01", "06-30"],
- "Canada": ["04-01", "03-31"],
- "Costa Rica": ["10-01", "09-30"],
- "Egypt": ["07-01", "06-30"],
- "Hong Kong": ["04-01", "03-31"],
- "India": ["04-01", "03-31"],
- "Iran": ["06-23", "06-22"],
- "Italy": ["07-01", "06-30"],
- "Myanmar": ["04-01", "03-31"],
- "New Zealand": ["04-01", "03-31"],
- "Pakistan": ["07-01", "06-30"],
- "Singapore": ["04-01", "03-31"],
- "South Africa": ["03-01", "02-28"],
- "Thailand": ["10-01", "09-30"],
- "United Kingdom": ["04-01", "03-31"],
-}
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.json b/erpnext/setup/page/setup_wizard/setup_wizard.json
deleted file mode 100644
index e90c87c..0000000
--- a/erpnext/setup/page/setup_wizard/setup_wizard.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "creation": "2013-10-04 13:49:33.000000",
- "docstatus": 0,
- "doctype": "Page",
- "idx": 1,
- "modified": "2013-10-04 13:49:33.000000",
- "modified_by": "Administrator",
- "module": "Setup",
- "name": "setup-wizard",
- "owner": "Administrator",
- "page_name": "setup-wizard",
- "roles": [
- {
- "role": "System Manager"
- }
- ],
- "standard": "Yes",
- "title": "Setup Wizard"
-}
\ No newline at end of file
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard_message.html b/erpnext/setup/page/setup_wizard/setup_wizard_message.html
deleted file mode 100644
index e2f6bbc..0000000
--- a/erpnext/setup/page/setup_wizard/setup_wizard_message.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<div class="container setup-wizard-slide">
- <img class="img-responsive setup-wizard-message-image" src="{%= image %}">
-
- <p class="text-center lead">{%= title %}</p>
-
- <p class="text-center">{%= message %}</p>
-</div>
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard_page.html b/erpnext/setup/page/setup_wizard/setup_wizard_page.html
deleted file mode 100644
index 0067317..0000000
--- a/erpnext/setup/page/setup_wizard/setup_wizard_page.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<div class="container setup-wizard-slide {%= css_class %}" data-slide-name="{%= name %}">
- <div class="text-center setup-wizard-progress text-extra-muted">
- {% for (var i=0; i < slides_count; i++) { %}
- <i class="icon-fixed-width {% if (i+1==step) { %} icon-circle {% } else { %} icon-circle-blank {% } %}"></i>
- {% } %}
- </div>
- <p class="text-center lead">{%= title %}</p>
- <div class="row">
- <div class="col-sm-12">
- {% if (help) { %} <p class="text-center">{%= help %}</p> {% } %}
- <div class="form"></div>
- </div>
- </div>
- <div class="footer text-center">
- <div>
- <a class="prev-btn hide grey small">{%= __("Previous") %}</a>
- <a class="next-btn hide btn btn-primary btn-sm">{%= __("Next") %}</a>
- <a class="complete-btn hide btn btn-primary btn-sm"><b>{%= __("Complete Setup") %}</b></a>
- </div>
- </div>
-</div>
diff --git a/erpnext/setup/page/setup_wizard/__init__.py b/erpnext/setup/setup_wizard/__init__.py
similarity index 100%
rename from erpnext/setup/page/setup_wizard/__init__.py
rename to erpnext/setup/setup_wizard/__init__.py
diff --git a/erpnext/setup/page/setup_wizard/data/sample_blog_post.html b/erpnext/setup/setup_wizard/data/sample_blog_post.html
similarity index 100%
rename from erpnext/setup/page/setup_wizard/data/sample_blog_post.html
rename to erpnext/setup/setup_wizard/data/sample_blog_post.html
diff --git a/erpnext/setup/page/setup_wizard/data/sample_home_page.css b/erpnext/setup/setup_wizard/data/sample_home_page.css
similarity index 100%
rename from erpnext/setup/page/setup_wizard/data/sample_home_page.css
rename to erpnext/setup/setup_wizard/data/sample_home_page.css
diff --git a/erpnext/setup/page/setup_wizard/data/sample_home_page.html b/erpnext/setup/setup_wizard/data/sample_home_page.html
similarity index 100%
rename from erpnext/setup/page/setup_wizard/data/sample_home_page.html
rename to erpnext/setup/setup_wizard/data/sample_home_page.html
diff --git a/erpnext/setup/page/setup_wizard/default_website.py b/erpnext/setup/setup_wizard/default_website.py
similarity index 90%
rename from erpnext/setup/page/setup_wizard/default_website.py
rename to erpnext/setup/setup_wizard/default_website.py
index dbe3540..e8d4eb43 100644
--- a/erpnext/setup/page/setup_wizard/default_website.py
+++ b/erpnext/setup/setup_wizard/default_website.py
@@ -26,8 +26,8 @@
'<p>'+_("This is an example website auto-generated from ERPNext")+"</p>"+\
'<p><a class="btn btn-primary" href="/login">Login</a></p></div>',
"description": self.company + ":" + (self.tagline or ""),
- "css": frappe.get_template("setup/page/setup_wizard/data/sample_home_page.css").render(),
- "main_section": frappe.get_template("setup/page/setup_wizard/data/sample_home_page.html").render({
+ "css": frappe.get_template("setup/setup_wizard/data/sample_home_page.css").render(),
+ "main_section": frappe.get_template("setup/setup_wizard/data/sample_home_page.html").render({
"company": self.company, "tagline": (self.tagline or "")
})
}).insert()
@@ -80,7 +80,7 @@
"blogger": blogger.name,
"blog_category": blog_category.name,
"blog_intro": "My First Blog",
- "content": frappe.get_template("setup/page/setup_wizard/data/sample_blog_post.html").render(),
+ "content": frappe.get_template("setup/setup_wizard/data/sample_blog_post.html").render(),
}).insert()
def test():
diff --git a/erpnext/setup/page/setup_wizard/fixtures/industry_type.py b/erpnext/setup/setup_wizard/industry_type.py
similarity index 100%
rename from erpnext/setup/page/setup_wizard/fixtures/industry_type.py
rename to erpnext/setup/setup_wizard/industry_type.py
diff --git a/erpnext/setup/page/setup_wizard/install_fixtures.py b/erpnext/setup/setup_wizard/install_fixtures.py
similarity index 98%
rename from erpnext/setup/page/setup_wizard/install_fixtures.py
rename to erpnext/setup/setup_wizard/install_fixtures.py
index ba48a29..d3d0cb4 100644
--- a/erpnext/setup/page/setup_wizard/install_fixtures.py
+++ b/erpnext/setup/setup_wizard/install_fixtures.py
@@ -177,7 +177,7 @@
{'doctype': "Print Heading", 'print_heading': _("Debit Note")}
]
- from erpnext.setup.page.setup_wizard.fixtures.industry_type import get_industry_types
+ from erpnext.setup.setup_wizard.industry_type import get_industry_types
records += [{"doctype":"Industry Type", "industry": d} for d in get_industry_types()]
# records += [{"doctype":"Operation", "operation": d} for d in get_operations()]
diff --git a/erpnext/setup/page/setup_wizard/sample_data.py b/erpnext/setup/setup_wizard/sample_data.py
similarity index 100%
rename from erpnext/setup/page/setup_wizard/sample_data.py
rename to erpnext/setup/setup_wizard/sample_data.py
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
similarity index 85%
rename from erpnext/setup/page/setup_wizard/setup_wizard.py
rename to erpnext/setup/setup_wizard/setup_wizard.py
index 86c4625..90856ca 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -2,122 +2,60 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import frappe, json, copy
+import frappe, copy
-from frappe.utils import cstr, flt, getdate, strip
+from frappe.utils import cstr, flt, getdate
from frappe import _
from frappe.utils.file_manager import save_file
-from frappe.translate import (set_default_language, get_dict,
- get_lang_dict, send_translations, get_language_from_code)
+from frappe.translate import set_default_language
from frappe.geo.country_info import get_country_info
-from frappe.utils.nestedset import get_root_of
from .default_website import website_maker
import install_fixtures
from .sample_data import make_sample_data
from erpnext.accounts.utils import FiscalYearError
from erpnext.accounts.doctype.account.account import RootNotEditable
-@frappe.whitelist()
-def setup_account(args=None):
- try:
- if frappe.db.sql("select name from tabCompany"):
- frappe.throw(_("Setup Already Complete!!"))
+def setup_complete(args=None):
+ if frappe.db.sql("select name from tabCompany"):
+ frappe.throw(_("Setup Already Complete!!"))
- args = process_args(args)
+ if args.language and args.language != "english":
+ set_default_language(args.language)
- if args.language and args.language != "english":
- set_default_language(args.language)
+ frappe.clear_cache()
- frappe.clear_cache()
+ install_fixtures.install(args.get("country"))
- install_fixtures.install(args.get("country"))
+ update_user_name(args)
+ create_fiscal_year_and_company(args)
+ create_users(args)
+ set_defaults(args)
+ create_territories()
+ create_price_lists(args)
+ create_feed_and_todo()
+ create_email_digest()
+ create_letter_head(args)
+ create_taxes(args)
+ create_items(args)
+ create_customers(args)
+ create_suppliers(args)
+ frappe.local.message_log = []
- update_user_name(args)
- frappe.local.message_log = []
+ website_maker(args.company_name.strip(), args.company_tagline, args.name)
+ create_logo(args)
- create_fiscal_year_and_company(args)
- frappe.local.message_log = []
+ frappe.db.commit()
+ login_as_first_user(args)
+ frappe.db.commit()
+ frappe.clear_cache()
- create_users(args)
- frappe.local.message_log = []
+ if args.get("add_sample_data"):
+ try:
+ make_sample_data()
+ frappe.clear_cache()
+ except FiscalYearError:
+ pass
- set_defaults(args)
- frappe.local.message_log = []
-
- create_territories()
- frappe.local.message_log = []
-
- create_price_lists(args)
- frappe.local.message_log = []
-
- create_feed_and_todo()
- frappe.local.message_log = []
-
- create_email_digest()
- frappe.local.message_log = []
-
- create_letter_head(args)
- frappe.local.message_log = []
-
- create_taxes(args)
- frappe.local.message_log = []
-
- create_items(args)
- frappe.local.message_log = []
-
- create_customers(args)
- frappe.local.message_log = []
-
- create_suppliers(args)
- frappe.local.message_log = []
-
- frappe.db.set_default('desktop:home_page', 'desktop')
-
- website_maker(args.company_name.strip(), args.company_tagline, args.name)
- create_logo(args)
-
- frappe.db.commit()
-
- login_as_first_user(args)
-
- frappe.db.commit()
-
- frappe.clear_cache()
-
- if args.get("add_sample_data"):
- try:
- make_sample_data()
- frappe.clear_cache()
- except FiscalYearError:
- pass
-
- except:
- if args:
- traceback = frappe.get_traceback()
- for hook in frappe.get_hooks("setup_wizard_exception"):
- frappe.get_attr(hook)(traceback, args)
-
- raise
-
- else:
- for hook in frappe.get_hooks("setup_wizard_success"):
- frappe.get_attr(hook)(args)
-
-
-def process_args(args):
- if not args:
- args = frappe.local.form_dict
- if isinstance(args, basestring):
- args = json.loads(args)
-
- args = frappe._dict(args)
-
- # strip the whitespace
- for key, value in args.items():
- if isinstance(value, basestring):
- args[key] = strip(value)
-
- return args
def update_user_name(args):
if args.get("email"):
@@ -583,18 +521,3 @@
emp.flags.ignore_mandatory = True
emp.insert(ignore_permissions = True)
-@frappe.whitelist()
-def load_messages(language):
- frappe.clear_cache()
- set_default_language(language)
- m = get_dict("page", "setup-wizard")
- m.update(get_dict("boot"))
- send_translations(m)
- return frappe.local.lang
-
-@frappe.whitelist()
-def load_languages():
- return {
- "default_language": get_language_from_code(frappe.local.lang),
- "languages": sorted(get_lang_dict().keys())
- }
diff --git a/erpnext/setup/page/setup_wizard/test_setup_data.py b/erpnext/setup/setup_wizard/test_setup_data.py
similarity index 100%
rename from erpnext/setup/page/setup_wizard/test_setup_data.py
rename to erpnext/setup/setup_wizard/test_setup_data.py
diff --git a/erpnext/setup/page/setup_wizard/test_setup_wizard.py b/erpnext/setup/setup_wizard/test_setup_wizard.py
similarity index 69%
rename from erpnext/setup/page/setup_wizard/test_setup_wizard.py
rename to erpnext/setup/setup_wizard/test_setup_wizard.py
index acc2459..d5dd658 100644
--- a/erpnext/setup/page/setup_wizard/test_setup_wizard.py
+++ b/erpnext/setup/setup_wizard/test_setup_wizard.py
@@ -4,12 +4,12 @@
from __future__ import unicode_literals
import frappe
-from erpnext.setup.page.setup_wizard.test_setup_data import args
-from erpnext.setup.page.setup_wizard.setup_wizard import setup_account
+from frappe.desk.page.setup_wizard.test_setup_data import args
+from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
import frappe.utils.scheduler
if __name__=="__main__":
frappe.connect()
frappe.local.form_dict = frappe._dict(args)
- setup_account()
+ setup_complete()
frappe.utils.scheduler.disable_scheduler()
diff --git a/erpnext/setup/utils.py b/erpnext/setup/utils.py
index cb642f9..5b8dd04 100644
--- a/erpnext/setup/utils.py
+++ b/erpnext/setup/utils.py
@@ -32,9 +32,9 @@
def before_tests():
frappe.clear_cache()
# complete setup if missing
- from erpnext.setup.page.setup_wizard.setup_wizard import setup_account
+ from frappe.desk.page.setup_wizard.setup_wizard import setup_complete
if not frappe.get_list("Company"):
- setup_account({
+ setup_complete({
"currency" :"USD",
"first_name" :"Test",
"last_name" :"User",