updates to Setup Wizard, set language as first input

This commit is contained in:
Rushabh Mehta 2014-04-17 18:48:59 +05:30
parent dbfcd328fb
commit 52e618d0b2
7 changed files with 537 additions and 245 deletions

View File

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

View File

@ -9,8 +9,8 @@ $.extend(cur_frm.cscript, {
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,7 +38,7 @@ $.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",

View File

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

View File

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

View File

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

View File

@ -16,28 +16,27 @@ 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: '<h1 class="text-muted text-center"><i class="icon-magic"></i></h1>\
<h2 class="text-center">'+__('ERPNext Setup')+'</h2>\
<p class="text-center" style="margin: 0px 100px">' +
@ -55,6 +54,35 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
'</p>',
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",
@ -68,7 +96,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
{"fieldname": "password", "label": __("Password"), "fieldtype": "Password",
reqd:1},
{fieldtype:"Attach Image", fieldname:"attach_user",
label:"Attach Your User..."},
label: __("Attach Your Picture")},
],
help: __('The first user will become the System Manager (you can change that later).'),
onload: function(slide) {
@ -90,15 +118,15 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
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) {
@ -129,23 +157,23 @@ 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));
}
})
@ -155,23 +183,23 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
$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));
// }
// })
});
}
},
@ -182,8 +210,8 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
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")},
],
},
@ -232,33 +260,33 @@ 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"},
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,
@ -271,27 +299,27 @@ 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"},
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"},
])
@ -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 = $('<div class="setup-wizard-wrapper">').appendTo(this.parent);
},
get_message: function(html) {
return $(repl('<div class="panel panel-default">\
@ -380,39 +415,41 @@ frappe.wiz.Wizard = Class.extend({
frappe.wiz.WizardSlide = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.$wrapper = $("<div>").appendTo(this.wiz.parent);
},
make: function() {
var me = this;
this.$wrapper = $(repl('<div class="panel panel-default">\
if(this.$body) this.$body.remove();
this.$body = $(repl('<div class="panel panel-default">\
<div class="panel-heading">\
<div class="panel-title row">\
<div class="col-sm-8"><h3 style="margin: 0px;">\
<div class="col-sm-12"><h3 style="margin: 0px;">\
<i class="%(icon)s text-muted"></i> %(title)s</h3></div>\
<div class="col-sm-4 text-right"><a class="prev-btn hide btn btn-default">Previous</a> \
<a class="next-btn hide btn btn-primary">Next</a> \
<a class="complete-btn hide btn btn-primary"><b>Complete Setup</b></a>\
</div>\
</div>\
</div>\
<div class="panel-body">\
<div class="progress">\
<div class="progress-bar" style="width: %(width)s%"></div>\
</div>\
<br>\
<div class="row">\
<div class="col-sm-8 form"></div>\
<div class="col-sm-4 help">\
<p class="text-muted">%(help)s</p>\
<div class="col-sm-12">\
<p class="text-muted">%(help)s</p><br>\
<div class="form"></div>\
</div>\
</div>\
<hr>\
<div class="footer"></div>\
<div class="footer">\
<div class="text-right"><a class="prev-btn hide btn btn-default">Previous</a> \
<a class="next-btn hide btn btn-primary">'+__("Next")+'</a> \
<a class="complete-btn hide btn btn-primary"><b>'+__("Complete Setup")+'</b></a>\
</div>\
</div>\
</div>\
</div>', {help:this.help, title:this.title, main_title:this.wiz.title, step: this.id + 1,
</div>', {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);
.appendTo(this.$wrapper);
this.body = this.$wrapper.find(".form")[0];
this.body = this.$body.find(".form")[0];
if(this.fields) {
this.form = new frappe.ui.FieldGroup({
@ -426,14 +463,14 @@ frappe.wiz.WizardSlide = Class.extend({
}
if(this.id > 0) {
this.$prev = this.$wrapper.find('.prev-btn').removeClass("hide")
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")
this.$next = this.$body.find('.next-btn').removeClass("hide")
.click(function() {
me.values = me.form.get_values();
if(me.values===null)
@ -441,7 +478,7 @@ frappe.wiz.WizardSlide = Class.extend({
frappe.set_route(me.wiz.page_name, me.id+1 + "");
})
} else {
this.$complete = this.$wrapper.find('.complete-btn').removeClass("hide")
this.$complete = this.$body.find('.complete-btn').removeClass("hide")
.click(function() {
me.values = me.form.get_values();
if(me.values===null)

View File

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