From 52e618d0b2cf1f0a67f24c588c56d55bc8c812c6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 17 Apr 2014 18:48:59 +0530 Subject: [PATCH] updates to Setup Wizard, set language as first input --- erpnext/config/setup.py | 10 +- .../global_defaults/global_defaults.js | 14 +- .../global_defaults/global_defaults.json | 359 ++++++++++++++---- .../global_defaults/global_defaults.py | 19 - .../setup/page/setup_wizard/setup_wizard.css | 13 +- .../setup/page/setup_wizard/setup_wizard.js | 301 ++++++++------- .../setup/page/setup_wizard/setup_wizard.py | 66 +++- 7 files changed, 537 insertions(+), 245 deletions(-) diff --git a/erpnext/config/setup.py b/erpnext/config/setup.py index 5be7e8cdd7..6689dd7840 100644 --- a/erpnext/config/setup.py +++ b/erpnext/config/setup.py @@ -3,14 +3,14 @@ from frappe.widgets.moduleview import add_setup_section data = [ { - "label": _("Tools"), + "label": _("Settings"), "icon": "icon-wrench", "items": [ { "type": "doctype", "name": "Global Defaults", "label": _("Global Settings"), - "description": _("Set the Date & Number Formats, Default Currency, Current Fiscal Year, etc."), + "description": _("Set Default Values like Company, Currency, Current Fiscal Year, etc."), "hide_count": True } ] @@ -124,7 +124,7 @@ data = [ def get_data(): out = list(data) - + for module, label, icon in ( ("accounts", _("Accounts"), "icon-money"), ("stock", _("Stock"), "icon-truck"), @@ -132,7 +132,7 @@ def get_data(): ("buying", _("Buying"), "icon-shopping-cart"), ("hr", _("Human Resources"), "icon-group"), ("support", _("Support"), "icon-phone")): - + add_setup_section(out, "erpnext", module, label, icon) - return out \ No newline at end of file + return out diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.js b/erpnext/setup/doctype/global_defaults/global_defaults.js index 85d718ae79..546fbd469f 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.js +++ b/erpnext/setup/doctype/global_defaults/global_defaults.js @@ -5,12 +5,12 @@ $.extend(cur_frm.cscript, { onload: function(doc) { var me = this; this.timezone = doc.time_zone; - + frappe.call({ method: "frappe.country_info.get_country_timezone_info", callback: function(data) { - erpnext.country_info = data.message.country_info; - erpnext.all_timezones = data.message.all_timezones; + frappe.country_info = data.message.country_info; + frappe.all_timezones = data.message.all_timezones; me.set_timezone_options(); cur_frm.set_value("time_zone", me.timezone); } @@ -28,7 +28,7 @@ $.extend(cur_frm.cscript, { var timezones = []; if (this.frm.doc.country) { - var timezones = (erpnext.country_info[this.frm.doc.country].timezones || []).sort(); + var timezones = (frappe.country_info[this.frm.doc.country].timezones || []).sort(); } this.frm.set_value("time_zone", timezones[0]); @@ -38,10 +38,10 @@ $.extend(cur_frm.cscript, { set_timezone_options: function(filtered_options) { var me = this; if(!filtered_options) filtered_options = []; - var remaining_timezones = $.map(erpnext.all_timezones, function(v) + var remaining_timezones = $.map(frappe.all_timezones, function(v) { return filtered_options.indexOf(v)===-1 ? v : null; }); - this.frm.set_df_property("time_zone", "options", + this.frm.set_df_property("time_zone", "options", (filtered_options.concat([""]).concat(remaining_timezones)).join("\n")); } -}); \ No newline at end of file +}); diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.json b/erpnext/setup/doctype/global_defaults/global_defaults.json index 5a5f21e38a..6375babcbe 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.json +++ b/erpnext/setup/doctype/global_defaults/global_defaults.json @@ -1,174 +1,395 @@ { + "_last_update": null, + "_user_tags": null, + "allow_attach": null, "allow_copy": 1, - "creation": "2013-05-02 17:53:24.000000", + "allow_email": null, + "allow_import": null, + "allow_print": null, + "allow_rename": null, + "allow_trash": null, + "autoname": null, + "change_log": null, + "client_script": null, + "client_script_core": null, + "client_string": null, + "colour": null, + "creation": "2013-05-02 17:53:24", + "custom": null, + "default_print_format": null, + "description": null, "docstatus": 0, "doctype": "DocType", + "document_type": null, + "dt_template": null, "fields": [ { - "fieldname": "date_and_number_settings", + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, + "fieldname": "currency_settings", "fieldtype": "Section Break", - "label": "Date and Number Settings", - "permlevel": 0 - }, - { - "default": "dd-mm-yyyy", - "fieldname": "date_format", - "fieldtype": "Select", - "label": "Date Format", - "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": 1, + "label": "Currency Settings", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, "permlevel": 0, - "read_only": 0 - }, - { - "description": "This is the default number format. For currencies, please set the number format in the currency master.", - "fieldname": "number_format", - "fieldtype": "Select", - "label": "Number Format", - "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###", - "permlevel": 0, - "read_only": 0 - }, - { - "default": "3", - "description": "Precision for Float fields (quantities, discounts, percentages etc). Floats will be rounded up to specified decimals. Default = 3", - "fieldname": "float_precision", - "fieldtype": "Select", - "label": "Float Precision", - "options": "\n2\n3\n4\n5\n6", - "permlevel": 0, - "read_only": 0 + "print_hide": null, + "print_width": null, + "read_only": null, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, "description": "If disable, 'Rounded Total' field will not be visible in any transaction", "fieldname": "disable_rounded_total", "fieldtype": "Check", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": 1, "label": "Disable Rounded Total", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "currency_settings", - "fieldtype": "Section Break", - "label": "Currency Settings", - "permlevel": 0 + "print_hide": null, + "print_width": null, + "read_only": 0, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, "default": "INR", + "depends_on": null, + "description": null, "fieldname": "default_currency", "fieldtype": "Link", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": 1, "label": "Default Currency", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, "options": "Currency", "permlevel": 0, + "print_hide": null, + "print_width": null, "read_only": 0, - "reqd": 1 + "report_hide": null, + "reqd": 1, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, "description": "Do not show any symbol like $ etc next to currencies.", "fieldname": "hide_currency_symbol", "fieldtype": "Select", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": 1, "label": "Hide Currency Symbol", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, "options": "\nNo\nYes", "permlevel": 0, - "read_only": 0 + "print_hide": null, + "print_width": null, + "read_only": 0, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, "fieldname": "company", "fieldtype": "Section Break", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": 1, "label": "Company Settings", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, "permlevel": 0, - "read_only": 0 + "print_hide": null, + "print_width": null, + "read_only": 0, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, "fieldname": "default_company", "fieldtype": "Link", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, "label": "Default Company", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, "options": "Company", "permlevel": 0, + "print_hide": null, + "print_width": null, "read_only": 0, - "reqd": 0 + "report_hide": null, + "reqd": 0, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, "fieldname": "current_fiscal_year", "fieldtype": "Link", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, "label": "Current Fiscal Year", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, "options": "Fiscal Year", "permlevel": 0, + "print_hide": null, + "print_width": null, "read_only": 0, - "reqd": 1 + "report_hide": null, + "reqd": 1, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, "fieldname": "system", "fieldtype": "Section Break", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, "label": "System Settings", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, "permlevel": 0, - "read_only": 0 - }, - { - "description": "Session Expiry in Hours e.g. 06:00", - "fieldname": "session_expiry", - "fieldtype": "Data", - "label": "Session Expiry", - "permlevel": 0, - "read_only": 0 + "print_hide": null, + "print_width": null, + "read_only": 0, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, "fieldname": "country", "fieldtype": "Select", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, "label": "Country", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, "options": "link:Country", - "permlevel": 0 + "permlevel": 0, + "print_hide": null, + "print_width": null, + "read_only": null, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, + "description": null, "fieldname": "sms_sender_name", "fieldtype": "Data", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, "label": "SMS Sender Name", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, + "options": null, "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "column_break_3", - "fieldtype": "Column Break", - "permlevel": 0, - "read_only": 0 + "print_hide": null, + "print_width": null, + "read_only": 0, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null }, { + "allow_on_submit": null, + "default": null, + "depends_on": null, "description": "For Server Side Print Formats", "fieldname": "print_style", "fieldtype": "Select", + "hidden": null, + "ignore_restrictions": null, + "in_filter": null, + "in_list_view": null, "label": "Print Format Style", + "no_column": null, + "no_copy": null, + "oldfieldname": null, + "oldfieldtype": null, "options": "Standard\nClassic\nModern\nSpartan", "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "time_zone", - "fieldtype": "Select", - "label": "Time Zone", - "permlevel": 0 + "print_hide": null, + "print_width": null, + "read_only": 0, + "report_hide": null, + "reqd": null, + "search_index": null, + "set_only_once": null, + "trigger": null, + "width": null } ], + "hide_heading": null, "hide_toolbar": 0, "icon": "icon-cog", "idx": 1, "in_create": 1, + "in_dialog": null, + "is_submittable": null, + "is_transaction_doc": null, "issingle": 1, - "modified": "2014-02-19 19:11:58.000000", + "istable": null, + "max_attachments": null, + "menu_index": null, + "modified": "2014-04-17 16:58:54.093191", "modified_by": "Administrator", "module": "Setup", "name": "Global Defaults", + "name_case": null, "owner": "Administrator", + "parent": null, + "parent_node": null, + "parentfield": null, + "parenttype": null, "permissions": [ { "amend": 0, "cancel": 0, "create": 1, + "delete": null, + "email": null, + "export": null, + "import": null, + "match": null, "permlevel": 0, + "print": null, "read": 1, "report": 0, + "restrict": null, + "restricted": null, "role": "System Manager", "submit": 0, "write": 1 } ], - "read_only": 1 + "plugin": null, + "print_outline": null, + "read_only": 1, + "read_only_onload": null, + "search_fields": null, + "section_style": null, + "server_code": null, + "server_code_compiled": null, + "server_code_core": null, + "server_code_error": null, + "show_in_menu": null, + "smallicon": null, + "subject": null, + "tag_fields": null, + "title_field": null, + "use_template": null, + "version": null } \ No newline at end of file diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py index 90861dec2a..a6db2babcb 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.py +++ b/erpnext/setup/doctype/global_defaults/global_defaults.py @@ -4,9 +4,7 @@ from __future__ import unicode_literals """Global Defaults""" import frappe -from frappe import _ import frappe.defaults -from frappe.utils import cint keydict = { # "key in defaults": "key in Global Defaults" @@ -15,11 +13,7 @@ keydict = { 'company': 'default_company', 'currency': 'default_currency', 'hide_currency_symbol':'hide_currency_symbol', - 'date_format': 'date_format', - 'number_format': 'number_format', - 'float_precision': 'float_precision', 'account_url':'account_url', - 'session_expiry': 'session_expiry', 'disable_rounded_total': 'disable_rounded_total', } @@ -29,9 +23,6 @@ class GlobalDefaults(Document): def on_update(self): """update defaults""" - self.validate_session_expiry() - self.set_country_and_timezone() - for key in keydict: frappe.db.set_default(key, self.get(keydict[key], '')) @@ -53,15 +44,5 @@ class GlobalDefaults(Document): # clear cache frappe.clear_cache() - def validate_session_expiry(self): - if self.session_expiry: - parts = self.session_expiry.split(":") - if len(parts)!=2 or not (cint(parts[0]) or cint(parts[1])): - frappe.throw(_("Session Expiry must be in format {0}").format("hh:mm")) - - def set_country_and_timezone(self): - frappe.db.set_default("country", self.country) - frappe.db.set_default("time_zone", self.time_zone) - def get_defaults(self): return frappe.defaults.get_defaults() diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.css b/erpnext/setup/page/setup_wizard/setup_wizard.css index 386715f9ce..519bc274be 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.css +++ b/erpnext/setup/page/setup_wizard/setup_wizard.css @@ -1,7 +1,16 @@ +#page-setup-wizard { + position: fixed; + top: 0px; bottom: 0px; + left: 0px; right: 0px; + overflow: auto; + padding-top: 60px; +} +.setup-wizard-wrapper { + margin: 0px auto; + width: 600px; +} #page-setup-wizard .panel { background-color: #fff; - position: fixed; top:0; left: 0; width:100%; height:100%; - overflow: auto; } #page-setup-wizard .panel-body { diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js index fbc5d02417..9bddf515da 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.js +++ b/erpnext/setup/page/setup_wizard/setup_wizard.js @@ -1,11 +1,11 @@ -frappe.pages['setup-wizard'].onload = function(wrapper) { +frappe.pages['setup-wizard'].onload = function(wrapper) { if(sys_defaults.company) { frappe.set_route("desktop"); return; } $(".navbar:first").toggle(false); $("body").css({"padding-top":"30px"}); - + var wizard_settings = { page_name: "setup-wizard", parent: wrapper, @@ -16,59 +16,87 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { method: "erpnext.setup.page.setup_wizard.setup_wizard.setup_account", args: values, callback: function(r) { - if(r.exc) { - var d = msgprint(__("There were errors.")); - d.custom_onhide = function() { - frappe.set_route(erpnext.wiz.page_name, "0"); + wiz.show_complete(); + setTimeout(function() { + if(user==="Administrator") { + msgprint(__("Login with your new User ID") + ":" + values.email); + setTimeout(function() { + frappe.app.logout(); + }, 2000); + } else { + window.location = "/desk"; } - } else { - wiz.show_complete(); - setTimeout(function() { - if(user==="Administrator") { - msgprint(__("Login with your new User ID") + ":" + values.email); - setTimeout(function() { - frappe.app.logout(); - }, 2000); - } else { - window.location = "/desk"; - } - }, 2000); + }, 2000); + }, + error: function(r) { + var d = msgprint(__("There were errors.")); + d.custom_onhide = function() { + frappe.set_route(erpnext.wiz.page_name, "0"); } } }) }, - title: __("ERPNext Setup Guide"), + title: __("Welcome"), welcome_html: '

\

'+__('ERPNext Setup')+'

\ -

' + - __('Welcome to ERPNext. Over the next few minutes we will help you setup your ERPNext account. Try and fill in as much information as you have even if it takes a bit longer. It will save you a lot of time later. Good Luck!') + +

' + + __('Welcome to ERPNext. Over the next few minutes we will help you setup your ERPNext account. Try and fill in as much information as you have even if it takes a bit longer. It will save you a lot of time later. Good Luck!') + '

', working_html: '

\

'+__('Setting up...')+'

\ -

' + - __('Sit tight while your system is being setup. This may take a few moments.') + +

' + + __('Sit tight while your system is being setup. This may take a few moments.') + '

', complete_html: '

\

'+__('Setup Complete!')+'

\ -

' + - __('Your setup is complete. Refreshing...') + +

' + + __('Your setup is complete. Refreshing...') + '

', slides: [ // User + { + title: __("Select Your Language"), + icon: "icon-globe", + fields: [ + {"fieldname": "language", "label": __("Language"), "fieldtype": "Select", + options: ["english", "العربية", "deutsch", "ελληνικά", "español", "français", "हिंदी", "hrvatski", + "italiano", "nederlands", "português brasileiro", "português", "српски", "தமிழ்", + "ไทย", "中国(简体", "中國(繁體"], reqd:1}, + ], + help: __("Welcome to ERPNext. Please select your language to begin the Setup Wizard."), + onload: function(slide) { + slide.get_input("language").on("change", function() { + var lang = $(this).val(); + frappe.call({ + method: "erpnext.setup.page.setup_wizard.setup_wizard.load_messages", + args: { + language: lang + }, + callback: function(r) { + // re-render all slides + $.each(slide.wiz.slide_dict, function(key, s) { + s.make(); + }); + slide.get_input("language").val(lang); + } + }) + }); + } + }, { title: __("The First User: You"), icon: "icon-user", fields: [ - {"fieldname": "first_name", "label": __("First Name"), "fieldtype": "Data", + {"fieldname": "first_name", "label": __("First Name"), "fieldtype": "Data", reqd:1}, - {"fieldname": "last_name", "label": __("Last Name"), "fieldtype": "Data", + {"fieldname": "last_name", "label": __("Last Name"), "fieldtype": "Data", reqd:1}, - {"fieldname": "email", "label": __("Email Id"), "fieldtype": "Data", + {"fieldname": "email", "label": __("Email Id"), "fieldtype": "Data", reqd:1, "description":"Your Login Id", "options":"Email"}, - {"fieldname": "password", "label": __("Password"), "fieldtype": "Password", + {"fieldname": "password", "label": __("Password"), "fieldtype": "Password", reqd:1}, - {fieldtype:"Attach Image", fieldname:"attach_user", - label:"Attach Your User..."}, + {fieldtype:"Attach Image", fieldname:"attach_user", + label: __("Attach Your Picture")}, ], help: __('The first user will become the System Manager (you can change that later).'), onload: function(slide) { @@ -77,28 +105,28 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { 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); - + delete slide.form.fields_dict.email; delete slide.form.fields_dict.password; } } }, - + // Organization { title: __("The Organization"), icon: "icon-building", fields: [ {fieldname:'company_name', label: __('Company Name'), fieldtype:'Data', reqd:1, - placeholder: 'e.g. "My Company LLC"'}, + placeholder: __('e.g. "My Company LLC"')}, {fieldname:'company_abbr', label: __('Company Abbreviation'), fieldtype:'Data', - placeholder:'e.g. "MC"',reqd:1}, - {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}, + placeholder: __('e.g. "MC"'),reqd:1}, + {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}, {fieldname:'company_tagline', label: __('What does it do?'), fieldtype:'Data', - placeholder:'e.g. "Build tools for builders"', reqd:1}, + placeholder:__('e.g. "Build tools for builders"'), reqd:1}, ], help: __('The name of your company for which you are setting up this system.'), onload: function(slide) { @@ -109,7 +137,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { }).val(frappe.boot.sysdefaults.company_name || "").trigger("change"); slide.get_input("fy_start_date").on("change", function() { - var year_end_date = + 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)); @@ -117,7 +145,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { }); } }, - + // Country { title: __("Country, Timezone and Currency"), @@ -129,64 +157,64 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { options: "", fieldtype: 'Select'}, {fieldname:'timezone', label: __('Time Zone'), reqd:1, options: "", fieldtype: 'Select'}, - {fieldname:'chart_of_accounts', label: __('Chart of Accounts'), - options: "", fieldtype: 'Select'} + // {fieldname:'chart_of_accounts', label: __('Chart of Accounts'), + // options: "", fieldtype: 'Select'} ], help: __('Select your home country and check the timezone and currency.'), onload: function(slide, form) { frappe.call({ method:"frappe.country_info.get_country_timezone_info", callback: function(data) { - erpnext.country_info = data.message.country_info; - erpnext.all_timezones = data.message.all_timezones; + frappe.country_info = data.message.country_info; + frappe.all_timezones = data.message.all_timezones; slide.get_input("country").empty() - .add_options([""].concat(keys(erpnext.country_info).sort())); + .add_options([""].concat(keys(frappe.country_info).sort())); slide.get_input("currency").empty() - .add_options(frappe.utils.unique([""].concat($.map(erpnext.country_info, + .add_options(frappe.utils.unique([""].concat($.map(frappe.country_info, function(opts, country) { return opts.currency; }))).sort()); slide.get_input("timezone").empty() - .add_options([""].concat(erpnext.all_timezones)); + .add_options([""].concat(frappe.all_timezones)); } }) - + slide.get_input("country").on("change", function() { var country = slide.get_input("country").val(); var $timezone = slide.get_input("timezone"); $timezone.empty(); // add country specific timezones first if(country){ - var timezone_list = erpnext.country_info[country].timezones || []; + var timezone_list = frappe.country_info[country].timezones || []; $timezone.add_options(timezone_list.sort()); - slide.get_input("currency").val(erpnext.country_info[country].currency); + slide.get_input("currency").val(frappe.country_info[country].currency); } // add all timezones at the end, so that user has the option to change it to any timezone - $timezone.add_options([""].concat(erpnext.all_timezones)); - + $timezone.add_options([""].concat(frappe.all_timezones)); + // get country specific chart of accounts - frappe.call({ - method: "erpnext.accounts.doctype.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([""].concat(r.message)); - } - }) + // frappe.call({ + // method: "erpnext.accounts.doctype.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([""].concat(r.message)); + // } + // }) }); } }, - + // Logo { icon: "icon-bookmark", title: __("Logo and Letter Heads"), help: __('Upload your letter head and logo - you can edit them later.'), fields: [ - {fieldtype:"Attach Image", fieldname:"attach_letterhead", label:"Attach Letterhead..."}, - {fieldtype:"Attach Image", fieldname:"attach_logo", label:"Attach Logo..."}, + {fieldtype:"Attach Image", fieldname:"attach_letterhead", label: __("Attach Letterhead")}, + {fieldtype:"Attach Image", fieldname:"attach_logo", label:__("Attach Logo")}, ], }, - + // Taxes { icon: "icon-money", @@ -202,7 +230,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { "help": __("List a few of your customers. They could be organizations or individuals."), "fields": [], }, - + // Items to Sell { icon: "icon-barcode", @@ -229,39 +257,39 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { ] } - + // taxes for(var i=1; i<4; i++) { - wizard_settings.slides[4].fields = wizard_settings.slides[4].fields.concat([ - {fieldtype:"Data", fieldname:"tax_"+ i, label:"Tax " + 1, placeholder:"e.g. VAT"}, + wizard_settings.slides[5].fields = wizard_settings.slides[5].fields.concat([ + {fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i, placeholder:__("e.g. VAT")}, {fieldtype:"Column Break"}, - {fieldtype:"Data", fieldname:"tax_rate_i", label:"Rate (%)", placeholder:"e.g. 5"}, + {fieldtype:"Data", fieldname:"tax_rate_i", label:__("Rate (%)"), placeholder:__("e.g. 5")}, {fieldtype:"Section Break"}, ]) } - + // customers for(var i=1; i<6; i++) { - wizard_settings.slides[5].fields = wizard_settings.slides[5].fields.concat([ - {fieldtype:"Data", fieldname:"customer_" + i, label:"Customer " + i, - placeholder:"Customer Name"}, + wizard_settings.slides[6].fields = wizard_settings.slides[6].fields.concat([ + {fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i, + placeholder:__("Customer Name")}, {fieldtype:"Column Break"}, - {fieldtype:"Data", fieldname:"customer_contact_" + i, - label:"Contact", placeholder:"Contact Name"}, + {fieldtype:"Data", fieldname:"customer_contact_" + i, + label:__("Contact"), placeholder:__("Contact Name")}, {fieldtype:"Section Break"} ]) } - + // products for(var i=1; i<6; i++) { - wizard_settings.slides[6].fields = wizard_settings.slides[6].fields.concat([ - {fieldtype:"Data", fieldname:"item_" + i, label:"Item " + i, - placeholder:"A Product or Service"}, + wizard_settings.slides[7].fields = wizard_settings.slides[7].fields.concat([ + {fieldtype:"Data", fieldname:"item_" + i, label:__("Item") + " " + i, + placeholder:__("A Product or Service")}, {fieldtype:"Column Break"}, - {fieldtype:"Attach", fieldname:"item_img_" + i, label:"Attach Image..."}, + {fieldtype:"Attach", fieldname:"item_img_" + i, label:__("Attach Image")}, {fieldtype:"Section Break"}, {fieldtype:"Column Break"}, - {fieldtype:"Select", label:"Group", fieldname:"item_group_" + i, + {fieldtype:"Select", label:"Group", fieldname:"item_group_" + i, options:["Products", "Services", "Raw Material", "Sub Assemblies"]}, {fieldtype:"Column Break"}, {fieldtype:"Select", fieldname:"item_uom_" + i, label:"UOM", @@ -271,32 +299,32 @@ frappe.pages['setup-wizard'].onload = function(wrapper) { } for(var i=1; i<6; i++) { - wizard_settings.slides[7].fields = wizard_settings.slides[7].fields.concat([ - {fieldtype:"Data", fieldname:"supplier_" + i, label:"Supplier " + i, + wizard_settings.slides[8].fields = wizard_settings.slides[8].fields.concat([ + {fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i, placeholder:"Supplier Name"}, {fieldtype:"Column Break"}, - {fieldtype:"Data", fieldname:"supplier_contact_" + i, - label:"Contact", placeholder:"Contact Name"}, + {fieldtype:"Data", fieldname:"supplier_contact_" + i, + label:"Contact", placeholder:__("Contact Name")}, {fieldtype:"Section Break"} ]) } for(var i=1; i<6; i++) { - wizard_settings.slides[8].fields = wizard_settings.slides[8].fields.concat([ - {fieldtype:"Data", fieldname:"item_buy_" + i, label:"Item " + i, - placeholder:"A Product or Service"}, + wizard_settings.slides[9].fields = wizard_settings.slides[9].fields.concat([ + {fieldtype:"Data", fieldname:"item_buy_" + i, label: __("Item") + " " + i, + placeholder:__("A Product or Service")}, {fieldtype:"Column Break"}, {fieldtype:"Section Break"}, {fieldtype:"Column Break"}, - {fieldtype:"Select", fieldname:"item_buy_group_" + i, label: "Group", + {fieldtype:"Select", fieldname:"item_buy_group_" + i, label: __("Group"), options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]}, {fieldtype:"Column Break"}, - {fieldtype:"Select", fieldname:"item_buy_uom_" + i, label: "UOM", + {fieldtype:"Select", fieldname:"item_buy_uom_" + i, label: __("UOM"), options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]}, {fieldtype:"Section Break"}, ]) } - + erpnext.wiz = new frappe.wiz.Wizard(wizard_settings) } @@ -310,9 +338,16 @@ frappe.provide("frappe.wiz"); frappe.wiz.Wizard = Class.extend({ init: function(opts) { $.extend(this, opts); + this.make(); this.slides = this.slides; this.slide_dict = {}; - this.show_welcome(); + //this.show_welcome(); + this.welcomed = true; + frappe.set_route(this.page_name, "0"); + }, + make: function() { + frappe.ui.set_user_background(null, "#page-setup-wizard"); + this.parent = $('
').appendTo(this.parent); }, get_message: function(html) { return $(repl('
\ @@ -320,19 +355,19 @@ frappe.wiz.Wizard = Class.extend({
', {html:html})) }, show_welcome: function() { - if(this.$welcome) + if(this.$welcome) return; var me = this; - this.$welcome = this.get_message(this.welcome_html + + this.$welcome = this.get_message(this.welcome_html + '

') .appendTo(this.parent); - + this.$welcome.find(".btn").click(function() { me.$welcome.toggle(false); me.welcomed = true; frappe.set_route(me.page_name, "0"); }) - + this.current_slide = {"$wrapper": this.$welcome}; }, show_working: function() { @@ -350,15 +385,15 @@ frappe.wiz.Wizard = Class.extend({ return; } id = cint(id); - if(this.current_slide && this.current_slide.id===id) + if(this.current_slide && this.current_slide.id===id) return; if(!this.slide_dict[id]) { this.slide_dict[id] = new frappe.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.toggle(true); }, @@ -380,40 +415,42 @@ frappe.wiz.Wizard = Class.extend({ frappe.wiz.WizardSlide = Class.extend({ init: function(opts) { $.extend(this, opts); + this.$wrapper = $("
").appendTo(this.wiz.parent); }, make: function() { var me = this; - this.$wrapper = $(repl('
\ + if(this.$body) this.$body.remove(); + this.$body = $(repl('
\
\
\ -

\ +

\ %(title)s

\ - \

\
\
\
\
\
\ -
\
\ -
\ -
\ -

%(help)s

\ +
\ +

%(help)s


\ +
\
\
\
\ - \ + \
\ -
', {help:this.help, title:this.title, main_title:this.wiz.title, step: this.id + 1, +
', {help: __(this.help), title:__(this.title), main_title:__(this.wiz.title), step: this.id + 1, width: (flt(this.id + 1) / (this.wiz.slides.length+1)) * 100, icon:this.icon})) - .appendTo(this.wiz.parent); - - this.body = this.$wrapper.find(".form")[0]; - + .appendTo(this.$wrapper); + + this.body = this.$body.find(".form")[0]; + if(this.fields) { this.form = new frappe.ui.FieldGroup({ fields: this.fields, @@ -424,32 +461,32 @@ frappe.wiz.WizardSlide = Class.extend({ } else { $(this.body).html(this.html) } - + if(this.id > 0) { - this.$prev = this.$wrapper.find('.prev-btn').removeClass("hide") - .click(function() { - frappe.set_route(me.wiz.page_name, me.id-1 + ""); + 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.$wrapper.find('.next-btn').removeClass("hide") - .click(function() { + this.$next = this.$body.find('.next-btn').removeClass("hide") + .click(function() { me.values = me.form.get_values(); - if(me.values===null) + if(me.values===null) return; - frappe.set_route(me.wiz.page_name, me.id+1 + ""); + frappe.set_route(me.wiz.page_name, me.id+1 + ""); }) } else { - this.$complete = this.$wrapper.find('.complete-btn').removeClass("hide") - .click(function() { + this.$complete = this.$body.find('.complete-btn').removeClass("hide") + .click(function() { me.values = me.form.get_values(); - if(me.values===null) + if(me.values===null) return; - me.wiz.on_complete(me.wiz); + me.wiz.on_complete(me.wiz); }) } - + if(this.onload) { this.onload(this); } @@ -458,4 +495,4 @@ frappe.wiz.WizardSlide = Class.extend({ get_input: function(fn) { return this.form.get_input(fn); } -}) \ No newline at end of file +}) diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index a2fb7d7b4f..863f6f81df 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -2,11 +2,12 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import frappe, json, base64 +import frappe, json -from frappe.utils import cint, cstr, getdate, now, nowdate, get_defaults -from frappe import _ +from frappe.utils import cstr, getdate from frappe.utils.file_manager import save_file +from frappe.translate import set_default_language, get_dict, get_lang_dict +from frappe.country_info import get_country_info @frappe.whitelist() def setup_account(args=None): @@ -19,27 +20,50 @@ def setup_account(args=None): args = json.loads(args) args = frappe._dict(args) + if args.language != "english": + set_default_language(args.language) + update_user_name(args) + frappe.local.message_log = [] + create_fiscal_year_and_company(args) + frappe.local.message_log = [] + 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') frappe.clear_cache() frappe.db.commit() - # suppress msgprints - frappe.local.message_log = [] - - return "okay" def update_user_name(args): if args.get("email"): @@ -116,13 +140,23 @@ def set_defaults(args): 'current_fiscal_year': args.curr_fiscal_year, 'default_currency': args.get('currency'), 'default_company':args.get('company_name'), - 'date_format': frappe.db.get_value("Country", args.get("country"), "date_format"), - "float_precision": 3, "country": args.get("country"), - "time_zone": args.get("time_zone") }) + global_defaults.save() + system_settings = frappe.get_doc("System Settings", "System Settings") + system_settings.update({ + "language": args.get("language"), + "time_zone": args.get("timezone"), + "float_precision": 3, + 'date_format': frappe.db.get_value("Country", args.get("country"), "date_format"), + 'number_format': get_country_info(args.get("country")).get("number_format", "#,###.##"), + }) + + system_settings.save() + + accounts_settings = frappe.get_doc("Accounts Settings") accounts_settings.auto_accounting_for_stock = 1 accounts_settings.save() @@ -317,7 +351,7 @@ def create_suppliers(args): def create_letter_head(args): if args.get("attach_letterhead"): - lh = frappe.get_doc({ + frappe.get_doc({ "doctype":"Letter Head", "letter_head_name": "Standard", "is_default": 1 @@ -348,3 +382,13 @@ def create_territories(): "parent_territory": root_territory, "is_group": "No" }).insert() + +@frappe.whitelist() +def load_messages(language): + lang = get_lang_dict()[language] + frappe.local.lang = lang + m = get_dict("page", "setup-wizard") + m.update(get_dict("boot")) + frappe.local.response["__messages"] = m + return lang +