From a6c361c00ea962720a36eda7d58c8a544267a5bc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 17 Feb 2015 15:55:36 +0530 Subject: [PATCH] Setup Wizard: Load number format based on currency #2627, login as first user on setup complete --- .../chart_of_accounts/chart_of_accounts.py | 2 +- .../setup/page/setup_wizard/setup_wizard.js | 35 ++++++++++++------- .../setup/page/setup_wizard/setup_wizard.py | 9 +++-- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py index 02ffb99aa8..6fd980e4b7 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py @@ -97,7 +97,7 @@ def get_charts_for_country(country): with open(os.path.join(os.path.dirname(__file__), "syscohada_syscohada_chart_template.json"), "r") as f: _get_chart_name(f.read()) - if len(charts) > 1: + if len(charts) != 1: charts.append("Standard") return charts diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js index a10dc80388..2dc93e0d0a 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.js +++ b/erpnext/setup/page/setup_wizard/setup_wizard.js @@ -83,11 +83,11 @@ erpnext.wiz.Wizard = Class.extend({ this.hide_current_slide(); this.current_slide = this.slide_dict[id]; - this.current_slide.$wrapper.toggle(true); + this.current_slide.$wrapper.removeClass("hidden"); }, hide_current_slide: function() { if(this.current_slide) { - this.current_slide.$wrapper.toggle(false); + this.current_slide.$wrapper.addClass("hidden"); this.current_slide = null; } }, @@ -103,7 +103,7 @@ erpnext.wiz.Wizard = Class.extend({ erpnext.wiz.WizardSlide = Class.extend({ init: function(opts) { $.extend(this, opts); - this.$wrapper = $("
") + this.$wrapper = $('') .appendTo(this.wiz.parent) .attr("data-slide-id", this.id); }, @@ -305,10 +305,11 @@ $.extend(erpnext.wiz, { $timezone.empty(); // add country specific timezones first - if(country){ + 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 @@ -320,6 +321,23 @@ $.extend(erpnext.wiz, { 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(); + 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); + }); + }); } }, @@ -585,14 +603,7 @@ $.extend(erpnext.wiz, { callback: function(r) { 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"; - } + window.location = "/desk"; }, 2000); }, error: function(r) { diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index 445aa3dc87..7b9dce90ca 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -75,6 +75,8 @@ def setup_account(args=None): website_maker(args.company_name.strip(), args.company_tagline, args.name) create_logo(args) + login_as_first_user(args) + frappe.clear_cache() frappe.db.commit() @@ -432,6 +434,11 @@ def create_territories(): "is_group": "No" }).insert() +def login_as_first_user(args): + if args.get("email"): + frappe.local.login_manager.user = args.get("email") + frappe.local.login_manager.post_login() + @frappe.whitelist() def load_messages(language): frappe.clear_cache() @@ -444,8 +451,6 @@ def load_messages(language): @frappe.whitelist() def load_languages(): - from frappe.sessions import get_geo_from_ip - return { "default_language": get_language_from_code(frappe.local.lang), "languages": sorted(get_lang_dict().keys())