Setup Wizard: Load number format based on currency #2627, login as first user on setup complete

This commit is contained in:
Anand Doshi 2015-02-17 15:55:36 +05:30
parent 0fe854692d
commit a6c361c00e
3 changed files with 31 additions and 15 deletions

View File

@ -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

View File

@ -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 = $("<div>")
this.$wrapper = $('<div class="slide-wrapper hidden"></div>')
.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) {

View File

@ -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())