diff --git a/public/js/startup.js b/public/js/startup.js
index 96953ad1d03..26e521981db 100644
--- a/public/js/startup.js
+++ b/public/js/startup.js
@@ -36,11 +36,18 @@ erpnext.startup.start = function() {
erpnext.toolbar.setup();
// complete registration
- if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete=='No')) {
+ if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete==='No')) {
wn.require("app/js/complete_setup.js");
erpnext.complete_setup.show();
- }
- if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
+ } else if(!wn.boot.customer_count) {
+ if(wn.get_route()[0]!=="Setup") {
+ msgprint(""
+ + wn._("Proceed to Setup") + "\
+
"+ + wn._("This message goes away after you create your first customer.")+ + "
", wn._("Welcome")); + } + } else if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) { var today = dateutil.str_to_obj(wn.boot.server_date); var expires_on = dateutil.str_to_obj(wn.boot.expires_on); var diff = dateutil.get_diff(expires_on, today); diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index 0f4f6a1e703..9cb0c482dbe 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -17,7 +17,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cint, cstr, getdate, now, nowdate +from webnotes.utils import cint, cstr, getdate, now, nowdate, get_defaults from webnotes.model.doc import Document, addchild from webnotes.model.code import get_obj from webnotes import session, form, msgprint @@ -26,16 +26,31 @@ class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl - # Account Setup - # --------------- def setup_account(self, args): import webnotes, json args = json.loads(args) webnotes.conn.begin() - curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start')) - #webnotes.msgprint(self.get_fy_details(args.get('fy_start'))) + self.update_profile_name(args) + add_all_roles_to(webnotes.session.user) + self.create_fiscal_year_and_company(args) + self.set_defaults(args) + create_territories() + self.create_price_lists(args) + self.create_feed_and_todo() + self.create_email_digest() + webnotes.clear_cache() + msgprint("Company setup is complete. This page will be refreshed in a moment.") + webnotes.conn.commit() + + return { + 'sys_defaults': get_defaults(), + 'user_fullname': (args.get('first_name') or '') + (args.get('last_name') + and (" " + args.get('last_name')) or '') + } + + def update_profile_name(self, args): args['name'] = webnotes.session.get('user') # Update Profile @@ -44,39 +59,54 @@ class DocType: UPDATE `tabProfile` SET first_name=%(first_name)s, last_name=%(last_name)s WHERE name=%(name)s AND docstatus<2""", args) - - + + def create_fiscal_year_and_company(self, args): + curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start')) # Fiscal Year - master_dict = {'Fiscal Year':{ + webnotes.bean([{ + "doctype":"Fiscal Year", 'year': curr_fiscal_year, 'year_start_date': fy_start_date, - }} - self.create_records(master_dict) - + }]).insert() # Company - master_dict = {'Company': { + webnotes.bean([{ + "doctype":"Company", 'company_name':args.get('company_name'), 'abbr':args.get('company_abbr'), 'default_currency':args.get('currency') - }} - self.create_records(master_dict) - + }]).insert() + + self.curr_fiscal_year = curr_fiscal_year + + def create_price_lists(self, args): + webnotes.bean({ + 'doctype': 'Price List', + 'price_list_name': 'Standard Selling', + "buying_or_selling": "Selling", + "currency": args["currency"] + }).insert(), + webnotes.bean({ + 'doctype': 'Price List', + 'price_list_name': 'Standard Buying', + "buying_or_selling": "Buying", + "currency": args["currency"] + }).insert(), + + def set_defaults(self, args): # enable default currency webnotes.conn.set_value("Currency", args.get("currency"), "enabled", 1) - def_args = { - 'current_fiscal_year':curr_fiscal_year, + global_defaults = webnotes.bean("Global Defaults", "Global Defaults") + global_defaults.doc.fields.update({ + 'current_fiscal_year': self.curr_fiscal_year, 'default_currency': args.get('currency'), 'default_company':args.get('company_name'), - 'date_format': webnotes.conn.get_value("Country", - args.get("country"), "date_format"), + 'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"), 'emp_created_by':'Naming Series', "float_precision": 4 - } - - # Set - self.set_defaults(def_args) + }) + global_defaults.save() webnotes.conn.set_value("Accounts Settings", None, "auto_inventory_accounting", 1) webnotes.conn.set_default("auto_inventory_accounting", 1) @@ -100,29 +130,20 @@ class DocType: buying_settings.doc.pr_required = "No" buying_settings.doc.maintain_same_rate = 1 buying_settings.save() - - cp_args = {} + + notification_control = webnotes.bean("Notification Control") + notification_control.doc.quotation = 1 + notification_control.doc.sales_invoice = 1 + notification_control.doc.purchase_order = 1 + notification_control.save() + + # control panel + cp = webnotes.doc("Control Panel", "Control Panel") for k in ['industry', 'country', 'timezone', 'company_name']: - cp_args[k] = args[k] - - self.set_cp_defaults(**cp_args) - - create_territories() - - self.create_feed_and_todo() - - self.create_email_digest() - - webnotes.clear_cache() - msgprint("Company setup is complete. This page will be refreshed in a moment.") - - import webnotes.utils - user_fullname = (args.get('first_name') or '') + (args.get('last_name') - and (" " + args.get('last_name')) or '') - - webnotes.conn.commit() - return {'sys_defaults': webnotes.utils.get_defaults(), 'user_fullname': user_fullname} - + cp.fields[k] = args[k] + + cp.save() + def create_feed_and_todo(self): """update activty feed and create todo for creation of item, customer, vendor""" import home @@ -131,24 +152,9 @@ class DocType: To Do List' + '"', '#6B24B3') d = Document('ToDo') - d.description = 'Create your first Customer' + d.description = 'Complete ERPNext Setup' d.priority = 'High' d.date = nowdate() - d.reference_type = 'Customer' - d.save(1) - - d = Document('ToDo') - d.description = 'Create your first Item' - d.priority = 'High' - d.date = nowdate() - d.reference_type = 'Item' - d.save(1) - - d = Document('ToDo') - d.description = 'Create your first Supplier' - d.priority = 'High' - d.date = nowdate() - d.reference_type = 'Supplier' d.save(1) def create_email_digest(self): @@ -206,42 +212,7 @@ class DocType: fy = cstr(curr_year) + '-' + cstr(curr_year+1) abbr = cstr(curr_year)[-2:] + '-' + cstr(curr_year+1)[-2:] return fy, stdt, abbr - - - def create_records(self, master_dict): - for d in master_dict.keys(): - rec = Document(d) - for fn in master_dict[d].keys(): - rec.fields[fn] = master_dict[d][fn] - - rec_obj = get_obj(doc=rec) - rec_obj.doc.save(1) - if hasattr(rec_obj, 'on_update'): - rec_obj.on_update() - - - # Set System Defaults - # -------------------- - def set_defaults(self, def_args): - ma_obj = get_obj('Global Defaults','Global Defaults') - for d in def_args.keys(): - ma_obj.doc.fields[d] = def_args[d] - ma_obj.doc.save() - ma_obj.on_update() - - - # Set Control Panel Defaults - # -------------------------- - def set_cp_defaults(self, industry, country, timezone, company_name): - cp = Document('Control Panel','Control Panel') - cp.company_name = company_name - cp.industry = industry - cp.time_zone = timezone - cp.country = country - cp.save() - # Create Profile - # -------------- def create_profile(self, user_email, user_fname, user_lname, pwd=None): pr = Document('Profile') pr.first_name = user_fname @@ -261,7 +232,7 @@ def add_all_roles_to(name): profile = webnotes.doc("Profile", name) for role in webnotes.conn.sql("""select name from tabRole"""): if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]: - d = profile.addchild("userroles", "UserRole") + d = profile.addchild("user_roles", "UserRole") d.role = role[0] d.insert() diff --git a/setup/page/setup/setup.css b/setup/page/setup/setup.css deleted file mode 100644 index bff44db14c9..00000000000 --- a/setup/page/setup/setup.css +++ /dev/null @@ -1,6 +0,0 @@ -.setup-column { - float: left; - width: 45%; - margin-right: 5%; - margin-bottom: 15px; -} \ No newline at end of file diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js index 788021a42aa..04a8d48517a 100644 --- a/setup/page/setup/setup.js +++ b/setup/page/setup/setup.js @@ -1,228 +1,180 @@ -// ERPNext: Copyright 2013 Web Notes Technologies Pvt Ltd -// GNU General Public License. See "license.txt" +wn.pages['Setup'].onload = function(wrapper) { + if(msg_dialog && msg_dialog.display) msg_dialog.hide(); + wn.ui.make_app_page({ + parent: wrapper, + title: 'Setup', + single_column: true + }); -wn.module_page["Setup"] = [ - { - title: wn._("Organization"), - icon: "icon-building", - items: [ - { - "label":wn._("Company"), - "doctype":"Company", - "description":wn._("List of companies (not customers / suppliers)") - }, - { - "doctype":"Fiscal Year", - "label": wn._("Fiscal Year"), - "description":wn._("Financial Years for books of accounts") - }, - { - "doctype":"Currency", - "label": wn._("Currency"), - "description": wn._("Enable / disable currencies.") - }, - ] - }, - { - title: wn._("Users"), - icon: "icon-group", - right: true, - items: [ - { - "doctype":"Profile", - "label": wn._("Profile"), - "description": wn._("Add/remove users, set roles, passwords etc") - }, - { - "page":"permission-manager", - label: wn._("Permission Manager"), - "description": wn._("Set permissions on transactions / masters") - }, - { - "page":"user-properties", - label: wn._("User Properties"), - "description":wn._("Set default values for users (also used for permissions).") - }, - { - "doctype":"Workflow", - label:wn._("Workflow"), - "description":wn._("Set workflow rules.") - }, - { - "doctype":"Authorization Rule", - label:wn._("Authorization Rule"), - "description":wn._("Restrict submission rights based on amount") - }, - ] - }, - { - title: wn._("Data"), - icon: "icon-table", - items: [ - { - "page":"data-import-tool", - label: wn._("Data Import"), - "description":wn._("Import data from spreadsheet (csv) files") - }, - { - "route":"Form/Global Defaults", - doctype: "Global Defaults", - label: wn._("Global Defaults"), - "description":wn._("Set default values for entry"), - }, - { - "route":"Form/Naming Series/Naming Series", - doctype: "Naming Series", - label: wn._("Manage Numbering Series"), - "description":wn._("Set multiple numbering series for transactions") - }, - { - "route":"Form/Rename Tool", - doctype: "Rename Tool", - label: wn._("Rename Tool"), - "description":wn._("Rename multiple items in one go") - }, - { - "route":"List/File Data", - doctype: "File Data", - label: wn._("File Manager"), - "description":wn._("List, delete uploaded files.") - }, - ] - }, - { - title: wn._("Branding and Printing"), - icon: "icon-print", - right: true, - items: [ - { - "doctype":"Letter Head", - label:wn._("Letter Head"), - "description":wn._("Letter heads for print") - }, - { - "doctype":"Print Format", - label:wn._("Print Format"), - "description":wn._("HTML print formats for quotes, invoices etc") - }, - { - "doctype":"Print Heading", - label:wn._("Print Heading"), - "description":wn._("Add headers for standard print formats") - }, - ] - }, - { - title: wn._("Email Settings"), - icon: "icon-envelope", - items: [ - { - "route":"Form/Email Settings/Email Settings", - doctype:"Email Settings", - label: wn._("Email Settings"), - "description":wn._("Out going mail server and support ticket mailbox") - }, - { - "route":"Form/Sales Email Settings", - doctype:"Sales Email Settings", - label: wn._("Sales Email Settings"), - "description":wn._("Extract Leads from sales email id e.g. sales@example.com") - }, - { - "route":"Form/Jobs Email Settings", - doctype:"Jobs Email Settings", - label: wn._("Jobs Email Settings"), - "description":wn._("Extract Job Applicant from jobs email id e.g. jobs@example.com") - }, - { - "route":"Form/Notification Control/Notification Control", - doctype:"Notification Control", - label: wn._("Notification Control"), - "description":wn._("Prompt email sending to customers and suppliers"), - }, - { - "doctype":"Email Digest", - label: wn._("Email Digest"), - "description":wn._("Daily, weekly, monthly email Digests") - }, - { - "route":"Form/SMS Settings/SMS Settings", - doctype:"SMS Settings", - label: wn._("SMS Settings"), - "description":wn._("Setup outgoing SMS via your bulk SMS provider") - }, - { - "route":"Form/SMS Center/SMS Center", - doctype:"SMS Center", - label: wn._("SMS Center"), - "description":wn._("Send bulk SMS to leads, customers, contacts") - }, - ] - }, - { - title: wn._("Customize"), - icon: "icon-wrench", - items: [ - { - "route":"Form/Customize Form/Customize Form", - doctype:"Customize Form", - label: wn._("Customize Form"), - "description":wn._("Change entry properties (hide fields, make mandatory etc)") - }, - { - "doctype":"Custom Field", - label: wn._("Custom Field"), - "description":wn._("Add fields to forms") - }, - { - "doctype":"Custom Script", - label: wn._("Custom Script"), - "description":wn._("Add custom code to forms") - }, - { - "route":"Form/Features Setup/Features Setup", - "description":wn._("Simplify entry forms by disabling features"), - doctype:"Features Setup", - label: wn._("Features Setup"), - }, - { - "page":"modules_setup", - label: wn._("Show / Hide Modules"), - "description":wn._("Show, hide modules") - }, - ] - }, - { - title: wn._("Administration"), - icon: "icon-rocket", - right: true, - items: [ - { - "page":"update-manager", - label: wn._("Update This Application"), - "description":wn._("Apply latest updates and patches to this app") - }, - { - "route":"Form/Backup Manager", - doctype:"Backup Manager", - label: wn._("Backup Manager"), - "description":wn._("Sync backups with remote tools like Dropbox etc.") - }, - { - "route":"List/Scheduler Log", - doctype:"Scheduler Log", - label: wn._("Scheduler Error Log"), - "description":wn._("Get a list of errors encountered by the Scheduler") - }, - ] - }, -] + wrapper.appframe.add_module_icon("Setup"); + + var body = $(wrapper).find(".layout-main"), + total = 0, + completed = 0; -pscript['onload_Setup'] = function(wrapper) { - wn.views.moduleview.make(wrapper, "Setup"); - if(wn.boot.expires_on) { - $(wrapper).find(".main-section") - .prepend("