Setup wizard refactor (#9441)
* cleaned up slides, yet to decide on master data * remove item_count * [fix] refresh slides on domain bug * UI test * set header image here in ERPNext * [minor] lint checks * [wiz] change autofilled fiscal year format * [minor] fixed date format to dd-mm-yyyy if fiscal year is not available for country
This commit is contained in:
parent
11df066ed0
commit
5e4c8ecd62
@ -1,4 +1,4 @@
|
|||||||
frappe.provide("erpnext.wiz");
|
frappe.provide("erpnext.setup");
|
||||||
|
|
||||||
frappe.pages['setup-wizard'].on_page_load = function(wrapper) {
|
frappe.pages['setup-wizard'].on_page_load = function(wrapper) {
|
||||||
if(frappe.sys_defaults.company) {
|
if(frappe.sys_defaults.company) {
|
||||||
@ -7,74 +7,118 @@ frappe.pages['setup-wizard'].on_page_load = function(wrapper) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function load_erpnext_slides() {
|
var erpnext_slides = [
|
||||||
$.extend(erpnext.wiz, {
|
{
|
||||||
select_domain: {
|
// Domain
|
||||||
|
name: 'domain',
|
||||||
domains: ["all"],
|
domains: ["all"],
|
||||||
title: __('Select your Domain'),
|
title: __('Select your Domain'),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldname:'domain', label: __('Domain'), fieldtype:'Select',
|
{
|
||||||
|
fieldname: 'domain', label: __('Domain'), fieldtype: 'Select',
|
||||||
options: [
|
options: [
|
||||||
{"label": __("Distribution"), "value": "Distribution"},
|
{ "label": __("Distribution"), "value": "Distribution" },
|
||||||
{"label": __("Education"), "value": "Education"},
|
{ "label": __("Education"), "value": "Education" },
|
||||||
{"label": __("Manufacturing"), "value": "Manufacturing"},
|
{ "label": __("Manufacturing"), "value": "Manufacturing" },
|
||||||
{"label": __("Retail"), "value": "Retail"},
|
{ "label": __("Retail"), "value": "Retail" },
|
||||||
{"label": __("Services"), "value": "Services"}
|
{ "label": __("Services"), "value": "Services" }
|
||||||
], reqd:1},
|
], reqd: 1
|
||||||
|
},
|
||||||
],
|
],
|
||||||
help: __('Select the nature of your business.'),
|
help: __('Select the nature of your business.'),
|
||||||
onload: function(slide) {
|
onload: function (slide) {
|
||||||
slide.get_input("domain").on("change", function() {
|
slide.get_input("domain").on("change", function () {
|
||||||
frappe.wiz.domain = $(this).val();
|
frappe.setup.domain = $(this).val();
|
||||||
frappe.wizard.refresh_slides();
|
frappe.wizard.refresh_slides();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
css_class: "single-column"
|
|
||||||
},
|
},
|
||||||
org: {
|
|
||||||
|
{
|
||||||
|
// Brand
|
||||||
|
name: 'brand',
|
||||||
domains: ["all"],
|
domains: ["all"],
|
||||||
title: __("The Organization"),
|
icon: "fa fa-bookmark",
|
||||||
icon: "fa fa-building",
|
title: __("The Brand"),
|
||||||
|
help: __('Upload your letter head and logo. (you can edit them later).'),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldname:'company_name',
|
{
|
||||||
label: frappe.wiz.domain==='Education' ?
|
fieldtype: "Attach Image", fieldname: "attach_logo",
|
||||||
|
label: __("Attach Logo"),
|
||||||
|
description: __("100px by 100px"),
|
||||||
|
is_private: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'company_name',
|
||||||
|
label: frappe.setup.domain === 'Education' ?
|
||||||
__('Institute Name') : __('Company Name'),
|
__('Institute Name') : __('Company Name'),
|
||||||
fieldtype:'Data', reqd:1},
|
fieldtype: 'Data', reqd: 1
|
||||||
{fieldname:'company_abbr',
|
},
|
||||||
label: frappe.wiz.domain==='Education' ?
|
{
|
||||||
|
fieldname: 'company_abbr',
|
||||||
|
label: frappe.setup.domain === 'Education' ?
|
||||||
__('Institute Abbreviation') : __('Company Abbreviation'),
|
__('Institute Abbreviation') : __('Company Abbreviation'),
|
||||||
fieldtype:'Data'},
|
fieldtype: 'Data'
|
||||||
{fieldname:'company_tagline',
|
}
|
||||||
|
],
|
||||||
|
onload: function(slide) {
|
||||||
|
this.bind_events(slide);
|
||||||
|
},
|
||||||
|
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) {
|
||||||
|
frappe.msgprint("Company Abbreviation cannot have more than 5 characters");
|
||||||
|
slide.get_field("company_abbr").set_input("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Organisation
|
||||||
|
name: 'organisation',
|
||||||
|
domains: ["all"],
|
||||||
|
title: __("Your Organization"),
|
||||||
|
icon: "fa fa-building",
|
||||||
|
help: (frappe.setup.domain === 'Education' ?
|
||||||
|
__('The name of the institute for which you are setting up this system.') :
|
||||||
|
__('The name of your company for which you are setting up this system.')),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
fieldname: 'company_tagline',
|
||||||
label: __('What does it do?'),
|
label: __('What does it do?'),
|
||||||
fieldtype:'Data',
|
fieldtype: 'Data',
|
||||||
placeholder: frappe.wiz.domain==='Education' ?
|
placeholder: frappe.setup.domain === 'Education' ?
|
||||||
__('e.g. "Primary School" or "University"') :
|
__('e.g. "Primary School" or "University"') :
|
||||||
__('e.g. "Build tools for builders"'),
|
__('e.g. "Build tools for builders"'),
|
||||||
reqd:1},
|
reqd: 1
|
||||||
{fieldname:'bank_account', label: __('Bank Name'), fieldtype:'Data', reqd:1},
|
},
|
||||||
{fieldname:'chart_of_accounts', label: __('Chart of Accounts'),
|
{ fieldname: 'bank_account', label: __('Bank Name'), fieldtype: 'Data', reqd: 1 },
|
||||||
options: "", fieldtype: 'Select'},
|
{
|
||||||
|
fieldname: 'chart_of_accounts', label: __('Chart of Accounts'),
|
||||||
// TODO remove this
|
options: "", fieldtype: 'Select'
|
||||||
{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: (frappe.wiz.domain==='Education' ?
|
|
||||||
__('The name of the institute for which you are setting up this system.'):
|
|
||||||
__('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);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
validate: function() {
|
{ fieldtype: "Section Break", label: "Financial Year" },
|
||||||
|
{ fieldname: 'fy_start_date', label: __('Start Date'), fieldtype: 'Date', reqd: 1 },
|
||||||
|
{ fieldtype: "Column Break" },
|
||||||
|
{ fieldname: 'fy_end_date', label: __('End Date'), fieldtype: 'Date', reqd: 1 },
|
||||||
|
],
|
||||||
|
|
||||||
|
onload: function (slide) {
|
||||||
|
this.load_chart_of_accounts(slide);
|
||||||
|
this.bind_events(slide);
|
||||||
|
this.set_fy_dates(slide);
|
||||||
|
},
|
||||||
|
|
||||||
|
validate: function () {
|
||||||
// validate fiscal year start and end dates
|
// validate fiscal year start and end dates
|
||||||
if (this.values.fy_start_date=='Invalid date' || this.values.fy_end_date=='Invalid date') {
|
if (this.values.fy_start_date == 'Invalid date' || this.values.fy_end_date == 'Invalid date') {
|
||||||
frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
|
frappe.msgprint(__("Please enter valid Financial Year Start and End Dates"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -87,44 +131,43 @@ function load_erpnext_slides() {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
css_class: "single-column",
|
set_fy_dates: function (slide) {
|
||||||
|
|
||||||
set_fy_dates: function(slide) {
|
|
||||||
var country = frappe.wizard.values.country;
|
var country = frappe.wizard.values.country;
|
||||||
|
|
||||||
if(country) {
|
if (country) {
|
||||||
var fy = erpnext.wiz.fiscal_years[country];
|
var fy = erpnext.setup.fiscal_years[country];
|
||||||
var current_year = moment(new Date()).year();
|
var current_year = moment(new Date()).year();
|
||||||
var next_year = current_year + 1;
|
var next_year = current_year + 1;
|
||||||
if(!fy) {
|
if (!fy) {
|
||||||
fy = ["01-01", "12-31"];
|
fy = ["01-01", "31-12"];
|
||||||
next_year = current_year;
|
next_year = current_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
var year_start_date = current_year + "-" + fy[0];
|
var year_start_date = current_year + "-" + fy[0];
|
||||||
if(year_start_date > frappe.datetime.get_today()) {
|
if (year_start_date > frappe.datetime.get_today()) {
|
||||||
next_year = current_year
|
next_year = current_year
|
||||||
current_year -= 1;
|
current_year -= 1;
|
||||||
}
|
}
|
||||||
slide.get_field("fy_start_date").set_input(current_year + "-" + fy[0]);
|
slide.get_field("fy_start_date").set_value(fy[0] + "-" + current_year);
|
||||||
slide.get_field("fy_end_date").set_input(next_year + "-" + fy[1]);
|
slide.get_field("fy_end_date").set_value(fy[1] + "-" + next_year);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
load_chart_of_accounts: function(slide) {
|
|
||||||
|
load_chart_of_accounts: function (slide) {
|
||||||
var country = frappe.wizard.values.country;
|
var country = frappe.wizard.values.country;
|
||||||
|
|
||||||
if(country) {
|
if (country) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.get_charts_for_country",
|
method: "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.get_charts_for_country",
|
||||||
args: {"country": country},
|
args: { "country": country },
|
||||||
callback: function(r) {
|
callback: function (r) {
|
||||||
if(r.message) {
|
if (r.message) {
|
||||||
slide.get_input("chart_of_accounts").empty()
|
slide.get_input("chart_of_accounts").empty()
|
||||||
.add_options(r.message);
|
.add_options(r.message);
|
||||||
|
|
||||||
if (r.message.length===1) {
|
if (r.message.length === 1) {
|
||||||
var field = slide.get_field("chart_of_accounts");
|
var field = slide.get_field("chart_of_accounts");
|
||||||
field.set_value(r.message[0]);
|
field.set_value(r.message[0]);
|
||||||
field.df.hidden = 1;
|
field.df.hidden = 1;
|
||||||
@ -136,330 +179,228 @@ function load_erpnext_slides() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
bind_events: function(slide) {
|
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) {
|
|
||||||
frappe.msgprint("Company Abbreviation cannot have more than 5 characters");
|
|
||||||
slide.get_field("company_abbr").set_input("");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO remove this
|
// TODO remove this
|
||||||
slide.get_input("fy_start_date").on("change", function() {
|
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.add_days(frappe.datetime.add_months(
|
||||||
frappe.datetime.user_to_obj(slide.get_input("fy_start_date").val()), 12), -1);
|
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));
|
slide.form.fields_dict.fy_end_date.set_value(frappe.datetime.obj_to_user(year_end_date));
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
branding: {
|
|
||||||
domains: ["all"],
|
|
||||||
icon: "fa fa-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)"),
|
|
||||||
is_private: 0
|
|
||||||
},
|
|
||||||
{fieldtype: "Column Break"},
|
|
||||||
{fieldtype:"Attach Image", fieldname:"attach_logo",
|
|
||||||
label:__("Attach Logo"),
|
|
||||||
description: __("100px by 100px"),
|
|
||||||
is_private: 0
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
css_class: "two-column"
|
{
|
||||||
},
|
// Taxes
|
||||||
|
name: 'taxes',
|
||||||
users: {
|
|
||||||
domains: ["all"],
|
|
||||||
icon: "fa fa-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 Address"), placeholder:__("user@example.com"),
|
|
||||||
options: "Email"},
|
|
||||||
{fieldtype:"Column Break"},
|
|
||||||
{fieldtype: "Check", fieldname: "user_sales_" + i,
|
|
||||||
label:__("Sales"), "default": 1,
|
|
||||||
hidden: frappe.wiz.domain==='Education' ? 1 : 0},
|
|
||||||
{fieldtype: "Check", fieldname: "user_purchaser_" + i,
|
|
||||||
label:__("Purchaser"), "default": 1,
|
|
||||||
hidden: frappe.wiz.domain==='Education' ? 1 : 0},
|
|
||||||
{fieldtype: "Check", fieldname: "user_accountant_" + i,
|
|
||||||
label:__("Accountant"), "default": 1,
|
|
||||||
hidden: frappe.wiz.domain==='Education' ? 1 : 0},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
css_class: "two-column"
|
|
||||||
},
|
|
||||||
|
|
||||||
taxes: {
|
|
||||||
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
||||||
icon: "fa fa-money",
|
icon: "fa fa-money",
|
||||||
title: __("Add Taxes"),
|
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."),
|
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": [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 4,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<4; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break"},
|
{fieldtype:"Section Break"},
|
||||||
{fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i,
|
{fieldtype:"Data", fieldname:"tax", label:__("Tax"),
|
||||||
placeholder:__("e.g. VAT") + " " + i},
|
placeholder:__("e.g. VAT")},
|
||||||
{fieldtype:"Column Break"},
|
{fieldtype:"Column Break"},
|
||||||
{fieldtype:"Float", fieldname:"tax_rate_" + i, label:__("Rate (%)"), placeholder:__("e.g. 5")},
|
{fieldtype:"Float", fieldname:"tax_rate", label:__("Rate (%)"), placeholder:__("e.g. 5")}
|
||||||
]);
|
]
|
||||||
}
|
|
||||||
},
|
|
||||||
css_class: "two-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
customers: {
|
{
|
||||||
|
// Customers
|
||||||
|
name: 'customers',
|
||||||
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
||||||
icon: "fa fa-group",
|
icon: "fa fa-group",
|
||||||
title: __("Your Customers"),
|
title: __("Add Customers"),
|
||||||
help: __("List a few of your customers. They could be organizations or individuals."),
|
help: __("List a few of your customers. They could be organizations or individuals."),
|
||||||
fields: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 6,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<6; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break"},
|
{fieldtype:"Section Break"},
|
||||||
{fieldtype:"Data", fieldname:"customer_" + i, label:__("Customer") + " " + i,
|
{fieldtype:"Data", fieldname:"customer", label:__("Customer"),
|
||||||
placeholder:__("Customer Name")},
|
placeholder:__("Customer Name")},
|
||||||
{fieldtype:"Column Break"},
|
{fieldtype:"Column Break"},
|
||||||
{fieldtype:"Data", fieldname:"customer_contact_" + i,
|
{fieldtype:"Data", fieldname:"customer_contact",
|
||||||
label:__("Contact Name") + " " + i, placeholder:__("Contact Name")}
|
label:__("Contact Name"), placeholder:__("Contact Name")}
|
||||||
])
|
],
|
||||||
}
|
|
||||||
slide.fields[1].reqd = 1;
|
|
||||||
},
|
|
||||||
css_class: "two-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
suppliers: {
|
{
|
||||||
|
// Suppliers
|
||||||
|
name: 'suppliers',
|
||||||
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
||||||
icon: "fa fa-group",
|
icon: "fa fa-group",
|
||||||
title: __("Your Suppliers"),
|
title: __("Your Suppliers"),
|
||||||
help: __("List a few of your suppliers. They could be organizations or individuals."),
|
help: __("List a few of your suppliers. They could be organizations or individuals."),
|
||||||
fields: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 6,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<6; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break"},
|
{fieldtype:"Section Break"},
|
||||||
{fieldtype:"Data", fieldname:"supplier_" + i, label:__("Supplier")+" " + i,
|
{fieldtype:"Data", fieldname:"supplier", label:__("Supplier"),
|
||||||
placeholder:__("Supplier Name")},
|
placeholder:__("Supplier Name")},
|
||||||
{fieldtype:"Column Break"},
|
{fieldtype:"Column Break"},
|
||||||
{fieldtype:"Data", fieldname:"supplier_contact_" + i,
|
{fieldtype:"Data", fieldname:"supplier_contact",
|
||||||
label:__("Contact Name") + " " + i, placeholder:__("Contact Name")},
|
label:__("Contact Name"), placeholder:__("Contact Name")},
|
||||||
])
|
]
|
||||||
}
|
|
||||||
slide.fields[1].reqd = 1;
|
|
||||||
},
|
|
||||||
css_class: "two-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
items: {
|
{
|
||||||
|
// Products
|
||||||
|
name: 'products',
|
||||||
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
domains: ['manufacturing', 'services', 'retail', 'distribution'],
|
||||||
icon: "fa fa-barcode",
|
icon: "fa fa-barcode",
|
||||||
title: __("Your Products or Services"),
|
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."),
|
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: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 6,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<6; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break", show_section_border: true},
|
{fieldtype:"Section Break", show_section_border: true},
|
||||||
{fieldtype:"Data", fieldname:"item_" + i, label:__("Item") + " " + i,
|
{fieldtype:"Data", fieldname:"item", label:__("Item"),
|
||||||
placeholder:__("A Product or Service")},
|
placeholder:__("A Product or Service")},
|
||||||
{fieldtype:"Select", label:__("Group"), fieldname:"item_group_" + i,
|
{fieldtype:"Select", label:__("Group"), fieldname:"item_group",
|
||||||
options:[__("Products"), __("Services"),
|
options:[__("Products"), __("Services"),
|
||||||
__("Raw Material"), __("Consumable"), __("Sub Assemblies")],
|
__("Raw Material"), __("Consumable"), __("Sub Assemblies")],
|
||||||
"default": __("Products")},
|
"default": __("Products")},
|
||||||
{fieldtype:"Select", fieldname:"item_uom_" + i, label:__("UOM"),
|
{fieldtype:"Select", fieldname:"item_uom", label:__("UOM"),
|
||||||
options:[__("Unit"), __("Nos"), __("Box"), __("Pair"), __("Kg"), __("Set"),
|
options:[__("Unit"), __("Nos"), __("Box"), __("Pair"), __("Kg"), __("Set"),
|
||||||
__("Hour"), __("Minute"), __("Litre"), __("Meter"), __("Gram")],
|
__("Hour"), __("Minute"), __("Litre"), __("Meter"), __("Gram")],
|
||||||
"default": __("Unit")},
|
"default": __("Unit")},
|
||||||
{fieldtype: "Check", fieldname: "is_sales_item_" + i, label:__("We sell this Item"), default: 1},
|
{fieldtype: "Check", fieldname: "is_sales_item", label:__("We sell this Item"), default: 1},
|
||||||
{fieldtype: "Check", fieldname: "is_purchase_item_" + i, label:__("We buy this Item")},
|
{fieldtype: "Check", fieldname: "is_purchase_item", label:__("We buy this Item")},
|
||||||
{fieldtype:"Column Break"},
|
{fieldtype:"Column Break"},
|
||||||
{fieldtype:"Currency", fieldname:"item_price_" + i, label:__("Rate")},
|
{fieldtype:"Currency", fieldname:"item_price", label:__("Rate")},
|
||||||
{fieldtype:"Attach Image", fieldname:"item_img_" + i, label:__("Attach Image"), is_private: 0},
|
{fieldtype:"Attach Image", fieldname:"item_img", label:__("Attach Image"), is_private: 0},
|
||||||
])
|
],
|
||||||
|
get_item_count: function() {
|
||||||
|
return this.item_count;
|
||||||
}
|
}
|
||||||
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});
|
|
||||||
slide.fields.push({fieldtype: "Check", fieldname: "setup_website",
|
|
||||||
label: __("Setup a simple website for my organization"), "default": 1});
|
|
||||||
},
|
|
||||||
css_class: "two-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
program: {
|
{
|
||||||
|
// Program
|
||||||
|
name: 'program',
|
||||||
domains: ["education"],
|
domains: ["education"],
|
||||||
title: __("Program"),
|
title: __("Program"),
|
||||||
help: __("Example: Masters in Computer Science"),
|
help: __("Example: Masters in Computer Science"),
|
||||||
fields: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 6,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<6; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break", show_section_border: true},
|
{fieldtype:"Section Break", show_section_border: true},
|
||||||
{fieldtype:"Data", fieldname:"program_" + i, label:__("Program") + " " + i, placeholder: __("Program Name")},
|
{fieldtype:"Data", fieldname:"program", label:__("Program"), placeholder: __("Program Name")},
|
||||||
])
|
],
|
||||||
}
|
|
||||||
slide.fields[1].reqd = 1;
|
|
||||||
},
|
|
||||||
css_class: "single-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
course: {
|
{
|
||||||
|
// Course
|
||||||
|
name: 'course',
|
||||||
domains: ["education"],
|
domains: ["education"],
|
||||||
title: __("Course"),
|
title: __("Course"),
|
||||||
help: __("Example: Basic Mathematics"),
|
help: __("Example: Basic Mathematics"),
|
||||||
fields: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 6,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<6; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break", show_section_border: true},
|
{fieldtype:"Section Break", show_section_border: true},
|
||||||
{fieldtype:"Data", fieldname:"course_" + i, label:__("Course") + " " + i, placeholder: __("Course Name")},
|
{fieldtype:"Data", fieldname:"course", label:__("Course"), placeholder: __("Course Name")},
|
||||||
])
|
]
|
||||||
}
|
|
||||||
slide.fields[1].reqd = 1;
|
|
||||||
},
|
|
||||||
css_class: "single-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
instructor: {
|
// Instructor
|
||||||
|
name: 'instructor',
|
||||||
domains: ["education"],
|
domains: ["education"],
|
||||||
title: __("Instructor"),
|
title: __("Instructor"),
|
||||||
help: __("People who teach at your organisation"),
|
help: __("People who teach at your organisation"),
|
||||||
fields: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 6,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<6; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break", show_section_border: true},
|
{fieldtype:"Section Break", show_section_border: true},
|
||||||
{fieldtype:"Data", fieldname:"instructor_" + i, label:__("Instructor") + " " + i, placeholder: __("Instructor Name")},
|
{fieldtype:"Data", fieldname:"instructor", label:__("Instructor"), placeholder: __("Instructor Name")},
|
||||||
])
|
]
|
||||||
}
|
|
||||||
slide.fields[1].reqd = 1;
|
|
||||||
},
|
|
||||||
css_class: "single-column"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
room: {
|
{
|
||||||
|
// Room
|
||||||
|
name: 'room',
|
||||||
domains: ["education"],
|
domains: ["education"],
|
||||||
title: __("Room"),
|
title: __("Room"),
|
||||||
help: __("Classrooms/ Laboratories etc where lectures can be scheduled."),
|
help: __("Classrooms/ Laboratories etc where lectures can be scheduled."),
|
||||||
fields: [],
|
add_more: 1,
|
||||||
before_load: function(slide) {
|
max_count: 4,
|
||||||
slide.fields = [];
|
fields: [
|
||||||
for(var i=1; i<4; i++) {
|
|
||||||
slide.fields = slide.fields.concat([
|
|
||||||
{fieldtype:"Section Break", show_section_border: true},
|
{fieldtype:"Section Break", show_section_border: true},
|
||||||
{fieldtype:"Data", fieldname:"room_" + i, label:__("Room") + " " + i},
|
{fieldtype:"Data", fieldname:"room", label:__("Room")},
|
||||||
{fieldtype:"Column Break"},
|
{fieldtype:"Column Break"},
|
||||||
{fieldtype:"Int", fieldname:"room_capacity_" + i, label:__("Room") + " " + i + " Capacity"},
|
{fieldtype:"Int", fieldname:"room_capacity", label:__("Room") + " Capacity"},
|
||||||
])
|
]
|
||||||
}
|
|
||||||
slide.fields[1].reqd = 1;
|
|
||||||
},
|
},
|
||||||
css_class: "two-column"
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Source: https://en.wikipedia.org/wiki/Fiscal_year
|
{
|
||||||
// default 1st Jan - 31st Dec
|
// last slide: Bootstrap
|
||||||
|
name: 'bootstrap',
|
||||||
erpnext.wiz.fiscal_years = {
|
domains: ["all"],
|
||||||
"Afghanistan": ["12-20", "12-21"],
|
title: __("Bootstrap"),
|
||||||
"Australia": ["07-01", "06-30"],
|
fields: [{fieldtype: "Section Break"},
|
||||||
"Bangladesh": ["07-01", "06-30"],
|
{fieldtype: "Check", fieldname: "add_sample_data",
|
||||||
"Canada": ["04-01", "03-31"],
|
label: __("Add a few sample records"), "default": 1},
|
||||||
"Costa Rica": ["10-01", "09-30"],
|
{fieldtype: "Check", fieldname: "setup_website",
|
||||||
"Egypt": ["07-01", "06-30"],
|
label: __("Setup a simple website for my organization"), "default": 1}
|
||||||
"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() {
|
|
||||||
load_erpnext_slides();
|
|
||||||
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.select_domain);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.org);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.branding);
|
|
||||||
|
|
||||||
if (!(frappe.boot.limits && frappe.boot.limits.users===1)) {
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.users);
|
|
||||||
}
|
}
|
||||||
|
];
|
||||||
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.taxes);
|
// Source: https://en.wikipedia.org/wiki/Fiscal_year
|
||||||
frappe.wiz.add_slide(erpnext.wiz.customers);
|
// default 1st Jan - 31st Dec
|
||||||
frappe.wiz.add_slide(erpnext.wiz.suppliers);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.items);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.program);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.course);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.instructor);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.room);
|
|
||||||
|
|
||||||
if(frappe.wizard && frappe.wizard.domain && frappe.wizard.domain !== 'Education') {
|
erpnext.setup.fiscal_years = {
|
||||||
frappe.wiz.welcome_page = "#welcome-to-erpnext";
|
"Afghanistan": ["20-12", "21-12"],
|
||||||
|
"Australia": ["01-07", "30-06"],
|
||||||
|
"Bangladesh": ["01-07", "30-06"],
|
||||||
|
"Canada": ["01-04", "31-03"],
|
||||||
|
"Costa Rica": ["01-10", "30-09"],
|
||||||
|
"Egypt": ["01-07", "30-06"],
|
||||||
|
"Hong Kong": ["01-04", "31-03"],
|
||||||
|
"India": ["01-04", "31-03"],
|
||||||
|
"Iran": ["23-06", "22-06"],
|
||||||
|
"Italy": ["01-07", "30-06"],
|
||||||
|
"Myanmar": ["01-04", "31-03"],
|
||||||
|
"New Zealand": ["01-04", "31-03"],
|
||||||
|
"Pakistan": ["01-07", "30-06"],
|
||||||
|
"Singapore": ["01-04", "31-03"],
|
||||||
|
"South Africa": ["01-03", "28-02"],
|
||||||
|
"Thailand": ["01-10", "30-09"],
|
||||||
|
"United Kingdom": ["01-04", "31-03"],
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.setup.on("before_load", function () {
|
||||||
|
erpnext_slides.map(frappe.setup.add_slide);
|
||||||
|
|
||||||
|
// change header brand
|
||||||
|
let $brand = $('header .setup-wizard-brand');
|
||||||
|
if($brand.find('.erpnext-icon').length === 0) {
|
||||||
|
$brand.find('.frappe-icon').hide();
|
||||||
|
$brand.append(`<span>
|
||||||
|
<img src="/assets/erpnext/images/erp-icon.svg" class="brand-icon erpnext-icon"
|
||||||
|
style="width:36px;"><span class="brand-name">ERPNext</span></span>`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var test_values_edu = {
|
var test_values_edu = {
|
||||||
"language":"english",
|
"language": "english",
|
||||||
"domain":"Education",
|
"domain": "Education",
|
||||||
"country":"India",
|
"country": "India",
|
||||||
"timezone":"Asia/Kolkata",
|
"timezone": "Asia/Kolkata",
|
||||||
"currency":"INR",
|
"currency": "INR",
|
||||||
"first_name":"Tester",
|
"first_name": "Tester",
|
||||||
"email":"test@example.com",
|
"email": "test@example.com",
|
||||||
"password":"test",
|
"password": "test",
|
||||||
"company_name":"Hogwarts",
|
"company_name": "Hogwarts",
|
||||||
"company_abbr":"HS",
|
"company_abbr": "HS",
|
||||||
"company_tagline":"School for magicians",
|
"company_tagline": "School for magicians",
|
||||||
"bank_account":"Gringotts Wizarding Bank",
|
"bank_account": "Gringotts Wizarding Bank",
|
||||||
"fy_start_date":"2016-04-01",
|
"fy_start_date": "2016-04-01",
|
||||||
"fy_end_date":"2017-03-31"
|
"fy_end_date": "2017-03-31"
|
||||||
}
|
}
|
||||||
|
47
erpnext/tests/ui/setup_wizard.js
Normal file
47
erpnext/tests/ui/setup_wizard.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const path_join = path.resolve;
|
||||||
|
const apps_path = path_join(__dirname, '..', '..', '..', '..');
|
||||||
|
const frappe_ui_tests_path = path_join(apps_path, 'frappe', 'frappe', 'tests', 'ui');
|
||||||
|
|
||||||
|
const login = require(frappe_ui_tests_path + "/login.js")['Login'];
|
||||||
|
const welcome = require(frappe_ui_tests_path + "/setup_wizard.js")['Welcome'];
|
||||||
|
const region = require(frappe_ui_tests_path + "/setup_wizard.js")['Region'];
|
||||||
|
const user = require(frappe_ui_tests_path + "/setup_wizard.js")['User'];
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
before: browser => {
|
||||||
|
browser
|
||||||
|
.url(browser.launch_url + '/login')
|
||||||
|
.waitForElementVisible('body', 5000);
|
||||||
|
},
|
||||||
|
'Login': login,
|
||||||
|
'Welcome': welcome,
|
||||||
|
'Region': region,
|
||||||
|
'User': user,
|
||||||
|
'Domain': browser => {
|
||||||
|
let slide_selector = '[data-slide-name="domain"]';
|
||||||
|
browser
|
||||||
|
.waitForElementVisible(slide_selector, 2000)
|
||||||
|
.setValue('select[data-fieldname="domain"]', "Manufacturing")
|
||||||
|
.click(slide_selector + ' .next-btn');
|
||||||
|
},
|
||||||
|
'Brand': browser => {
|
||||||
|
let slide_selector = '[data-slide-name="brand"]';
|
||||||
|
browser
|
||||||
|
.waitForElementVisible(slide_selector, 2000)
|
||||||
|
.setValue('input[data-fieldname="company_name"]', "Acme")
|
||||||
|
.click(slide_selector + " .next-btn");
|
||||||
|
},
|
||||||
|
'Organisation': browser => {
|
||||||
|
let slide_selector = '[data-slide-name="organisation"]';
|
||||||
|
browser
|
||||||
|
.waitForElementVisible(slide_selector, 2000)
|
||||||
|
.setValue('input[data-fieldname="company_tagline"]', "Build tools for Builders")
|
||||||
|
.setValue('input[data-fieldname="bank_account"]', "YNG")
|
||||||
|
.click(slide_selector + " .next-btn");
|
||||||
|
},
|
||||||
|
|
||||||
|
after: browser => {
|
||||||
|
browser.end();
|
||||||
|
},
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user