Fixes in Setup Wizard
This commit is contained in:
parent
da297dcfc5
commit
3c0d5cbab5
@ -9,43 +9,8 @@ frappe.pages['setup-wizard'].on_page_load = function(wrapper) {
|
|||||||
|
|
||||||
function load_erpnext_slides() {
|
function load_erpnext_slides() {
|
||||||
$.extend(erpnext.wiz, {
|
$.extend(erpnext.wiz, {
|
||||||
user: {
|
|
||||||
title: __("The First User: You"),
|
|
||||||
icon: "icon-user",
|
|
||||||
fields: [
|
|
||||||
{"fieldname": "first_name", "label": __("First Name"), "fieldtype": "Data",
|
|
||||||
reqd:1},
|
|
||||||
{"fieldname": "last_name", "label": __("Last Name"), "fieldtype": "Data"},
|
|
||||||
{"fieldname": "email", "label": __("Email Address"), "fieldtype": "Data",
|
|
||||||
reqd:1, "description": __("You will use it to Login"), "options":"Email"},
|
|
||||||
{"fieldname": "password", "label": __("Password"), "fieldtype": "Password",
|
|
||||||
reqd:1},
|
|
||||||
{fieldtype:"Attach Image", fieldname:"attach_user",
|
|
||||||
label: __("Attach Your Picture"), is_private: 0},
|
|
||||||
],
|
|
||||||
help: __('The first user will become the System Manager (you can change this later).'),
|
|
||||||
onload: function(slide) {
|
|
||||||
if(user!=="Administrator") {
|
|
||||||
slide.form.fields_dict.password.$wrapper.toggle(false);
|
|
||||||
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);
|
|
||||||
|
|
||||||
var user_image = frappe.get_cookie("user_image");
|
|
||||||
if(user_image) {
|
|
||||||
var $attach_user = slide.form.fields_dict.attach_user.$wrapper;
|
|
||||||
$attach_user.find(".missing-image").toggle(false);
|
|
||||||
$attach_user.find("img").attr("src", decodeURIComponent(user_image)).toggle(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete slide.form.fields_dict.email;
|
|
||||||
delete slide.form.fields_dict.password;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
css_class: "single-column"
|
|
||||||
},
|
|
||||||
|
|
||||||
org: {
|
org: {
|
||||||
|
app_name: "erpnext",
|
||||||
title: __("The Organization"),
|
title: __("The Organization"),
|
||||||
icon: "icon-building",
|
icon: "icon-building",
|
||||||
fields: [
|
fields: [
|
||||||
@ -160,6 +125,7 @@ function load_erpnext_slides() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
branding: {
|
branding: {
|
||||||
|
app_name: "erpnext",
|
||||||
icon: "icon-bookmark",
|
icon: "icon-bookmark",
|
||||||
title: __("The Brand"),
|
title: __("The Brand"),
|
||||||
help: __('Upload your letter head and logo. (you can edit them later).'),
|
help: __('Upload your letter head and logo. (you can edit them later).'),
|
||||||
@ -181,10 +147,11 @@ function load_erpnext_slides() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
users: {
|
users: {
|
||||||
|
app_name: "erpnext",
|
||||||
icon: "icon-money",
|
icon: "icon-money",
|
||||||
"title": __("Add Users"),
|
title: __("Add Users"),
|
||||||
"help": __("Add users to your organization, other than yourself"),
|
help: __("Add users to your organization, other than yourself"),
|
||||||
"fields": [],
|
fields: [],
|
||||||
before_load: function(slide) {
|
before_load: function(slide) {
|
||||||
slide.fields = [];
|
slide.fields = [];
|
||||||
for(var i=1; i<5; i++) {
|
for(var i=1; i<5; i++) {
|
||||||
@ -209,9 +176,10 @@ function load_erpnext_slides() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
taxes: {
|
taxes: {
|
||||||
|
app_name: "erpnext",
|
||||||
icon: "icon-money",
|
icon: "icon-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": [],
|
"fields": [],
|
||||||
before_load: function(slide) {
|
before_load: function(slide) {
|
||||||
slide.fields = [];
|
slide.fields = [];
|
||||||
@ -229,10 +197,11 @@ function load_erpnext_slides() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
customers: {
|
customers: {
|
||||||
|
app_name: "erpnext",
|
||||||
icon: "icon-group",
|
icon: "icon-group",
|
||||||
"title": __("Your Customers"),
|
title: __("Your 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": [],
|
fields: [],
|
||||||
before_load: function(slide) {
|
before_load: function(slide) {
|
||||||
slide.fields = [];
|
slide.fields = [];
|
||||||
for(var i=1; i<6; i++) {
|
for(var i=1; i<6; i++) {
|
||||||
@ -251,10 +220,11 @@ function load_erpnext_slides() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
suppliers: {
|
suppliers: {
|
||||||
|
app_name: "erpnext",
|
||||||
icon: "icon-group",
|
icon: "icon-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": [],
|
fields: [],
|
||||||
before_load: function(slide) {
|
before_load: function(slide) {
|
||||||
slide.fields = [];
|
slide.fields = [];
|
||||||
for(var i=1; i<6; i++) {
|
for(var i=1; i<6; i++) {
|
||||||
@ -273,10 +243,11 @@ function load_erpnext_slides() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
items: {
|
items: {
|
||||||
|
app_name: "erpnext",
|
||||||
icon: "icon-barcode",
|
icon: "icon-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": [],
|
fields: [],
|
||||||
before_load: function(slide) {
|
before_load: function(slide) {
|
||||||
slide.fields = [];
|
slide.fields = [];
|
||||||
for(var i=1; i<6; i++) {
|
for(var i=1; i<6; i++) {
|
||||||
@ -336,7 +307,6 @@ function load_erpnext_slides() {
|
|||||||
|
|
||||||
frappe.wiz.on("before_load", function() {
|
frappe.wiz.on("before_load", function() {
|
||||||
load_erpnext_slides();
|
load_erpnext_slides();
|
||||||
frappe.wiz.add_slide(erpnext.wiz.user);
|
|
||||||
frappe.wiz.add_slide(erpnext.wiz.org);
|
frappe.wiz.add_slide(erpnext.wiz.org);
|
||||||
frappe.wiz.add_slide(erpnext.wiz.branding);
|
frappe.wiz.add_slide(erpnext.wiz.branding);
|
||||||
frappe.wiz.add_slide(erpnext.wiz.users);
|
frappe.wiz.add_slide(erpnext.wiz.users);
|
||||||
|
@ -12,7 +12,7 @@ def after_install():
|
|||||||
frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
|
frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
|
||||||
set_single_defaults()
|
set_single_defaults()
|
||||||
feature_setup()
|
feature_setup()
|
||||||
from erpnext.setup.setup_wizard.setup_wizard import add_all_roles_to
|
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
|
||||||
add_all_roles_to("Administrator")
|
add_all_roles_to("Administrator")
|
||||||
add_web_forms()
|
add_web_forms()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
@ -20,7 +20,6 @@ def setup_complete(args=None):
|
|||||||
|
|
||||||
install_fixtures.install(args.get("country"))
|
install_fixtures.install(args.get("country"))
|
||||||
|
|
||||||
update_user_name(args)
|
|
||||||
create_fiscal_year_and_company(args)
|
create_fiscal_year_and_company(args)
|
||||||
create_users(args)
|
create_users(args)
|
||||||
set_defaults(args)
|
set_defaults(args)
|
||||||
@ -54,43 +53,8 @@ def setup_complete(args=None):
|
|||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def update_user_name(args):
|
|
||||||
if args.get("email"):
|
|
||||||
args['name'] = args.get("email")
|
|
||||||
|
|
||||||
_mute_emails, frappe.flags.mute_emails = frappe.flags.mute_emails, True
|
|
||||||
doc = frappe.get_doc({
|
|
||||||
"doctype":"User",
|
|
||||||
"email": args.get("email"),
|
|
||||||
"first_name": args.get("first_name"),
|
|
||||||
"last_name": args.get("last_name")
|
|
||||||
})
|
|
||||||
doc.flags.no_welcome_mail = True
|
|
||||||
doc.insert()
|
|
||||||
frappe.flags.mute_emails = _mute_emails
|
|
||||||
from frappe.auth import _update_password
|
|
||||||
_update_password(args.get("email"), args.get("password"))
|
|
||||||
|
|
||||||
else:
|
|
||||||
args['name'] = frappe.session.user
|
|
||||||
|
|
||||||
# Update User
|
|
||||||
if not args.get('last_name') or args.get('last_name')=='None':
|
|
||||||
args['last_name'] = None
|
|
||||||
frappe.db.sql("""update `tabUser` SET first_name=%(first_name)s,
|
|
||||||
last_name=%(last_name)s WHERE name=%(name)s""", args)
|
|
||||||
|
|
||||||
if args.get("attach_user"):
|
|
||||||
attach_user = args.get("attach_user").split(",")
|
|
||||||
if len(attach_user)==3:
|
|
||||||
filename, filetype, content = attach_user
|
|
||||||
fileurl = save_file(filename, content, "User", args.get("name"), decode=True).file_url
|
|
||||||
frappe.db.set_value("User", args.get("name"), "user_image", fileurl)
|
|
||||||
|
|
||||||
add_all_roles_to(args.get("name"))
|
|
||||||
|
|
||||||
def create_fiscal_year_and_company(args):
|
def create_fiscal_year_and_company(args):
|
||||||
|
if (args.get('fy_start_date')):
|
||||||
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype":"Fiscal Year",
|
"doctype":"Fiscal Year",
|
||||||
@ -98,8 +62,10 @@ def create_fiscal_year_and_company(args):
|
|||||||
'year_start_date': args.get('fy_start_date'),
|
'year_start_date': args.get('fy_start_date'),
|
||||||
'year_end_date': args.get('fy_end_date'),
|
'year_end_date': args.get('fy_end_date'),
|
||||||
}).insert()
|
}).insert()
|
||||||
|
args["curr_fiscal_year"] = curr_fiscal_year
|
||||||
|
|
||||||
# Company
|
# Company
|
||||||
|
if (args.get('company_name')):
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype":"Company",
|
"doctype":"Company",
|
||||||
'domain': args.get("industry"),
|
'domain': args.get("industry"),
|
||||||
@ -113,8 +79,6 @@ def create_fiscal_year_and_company(args):
|
|||||||
# Bank Account
|
# Bank Account
|
||||||
create_bank_account(args)
|
create_bank_account(args)
|
||||||
|
|
||||||
args["curr_fiscal_year"] = curr_fiscal_year
|
|
||||||
|
|
||||||
def create_bank_account(args):
|
def create_bank_account(args):
|
||||||
if args.get("bank_account"):
|
if args.get("bank_account"):
|
||||||
company_name = args.get('company_name').strip()
|
company_name = args.get('company_name').strip()
|
||||||
@ -440,14 +404,6 @@ def create_logo(args):
|
|||||||
frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
|
frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
|
||||||
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name").strip()))
|
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name").strip()))
|
||||||
|
|
||||||
def add_all_roles_to(name):
|
|
||||||
user = frappe.get_doc("User", name)
|
|
||||||
for role in frappe.db.sql("""select name from tabRole"""):
|
|
||||||
if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner", "Employee"]:
|
|
||||||
d = user.append("user_roles")
|
|
||||||
d.role = role[0]
|
|
||||||
user.save()
|
|
||||||
|
|
||||||
def create_territories():
|
def create_territories():
|
||||||
"""create two default territories, one for home country and one named Rest of the World"""
|
"""create two default territories, one for home country and one named Rest of the World"""
|
||||||
from frappe.utils.nestedset import get_root_of
|
from frappe.utils.nestedset import get_root_of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user