From 2f7e1abd0f372a0882047b322809bdbf7467a907 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 26 Jun 2013 17:20:12 +0530 Subject: [PATCH] [setup] new page + minor fixes --- public/js/startup.js | 13 +- setup/doctype/setup_control/setup_control.py | 165 ++++---- setup/page/setup/setup.css | 6 - setup/page/setup/setup.js | 400 ++++++++----------- setup/page/setup/setup.py | 244 +++++++++++ startup/boot.py | 8 +- startup/install.py | 8 +- 7 files changed, 505 insertions(+), 339 deletions(-) delete mode 100644 setup/page/setup/setup.css create mode 100644 setup/page/setup/setup.py 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("
Your ERPNext account will expire on " - + wn.datetime.global_date_format(wn.boot.expires_on) + "
"); + body.html('
\ +
') + + wn.call({ + method: "setup.page.setup.setup.get", + callback: function(r) { + if(r.message) { + body.empty(); + if(wn.boot.expires_on) { + $(body).prepend("
Account expires on " + + wn.datetime.global_date_format(wn.boot.expires_on) + "
"); + } + + $completed = $('

Setup Completed

\ +
') + .appendTo(body); + + $.each(r.message, function(i, item) { + render_item(item) + }); + + var completed_percent = cint(flt(completed) / total * 100) + "%"; + $completed + .find(".progress-bar") + .css({"width": completed_percent}); + $(body) + .find(".completed-percent") + .html("(" + completed_percent + ")"); + } + } + }); + + var render_item = function(item, dependency) { + if(item.type==="Section") { + $("

") + .css({"margin": "20px 0px 15px 0px"}) + .html(' ' + item.title).appendTo(body); + return; + } + var row = $('
') + .css({ + "margin-bottom": "7px", + "padding-bottom": "7px", + "border-bottom": "1px solid #eee" + }) + .appendTo(body); + + $('
').appendTo(row); + + if(item.type==="Link") { + var col = $('').appendTo(row); + + } else { + var col = $('
\ + '+ item.count +''+ + ' ' + (item.title || item.doctype) + '' + +'
') + .appendTo(row); + + if(dependency) + col.addClass("col-offset-1"); + else + $('
').appendTo(row); + + col.find(".badge") + .css({ + "background-color": (item.count ? "green" : "orange"), + "display": "inline-block", + "min-width": "40px" + }); + + total += 1; + if(item.count) + completed += 1; + } + + if(item.doctype) { + col.find(".badge") + .attr("data-doctype", item.doctype) + .css({"cursor": "pointer"}) + .click(function() { + wn.set_route("List", $(this).attr("data-doctype")) + }) + } + + // tree + $links = $('
').appendTo(row); + + if(item.tree) { + $(' Browse\ + | \ + Import') + .appendTo($links) + + $links.find(".view-link") + .attr("data-doctype", item.doctype) + .click(function() { + wn.set_route(item.tree, item.doctype); + }) + } else if(item.single) { + $(' Edit') + .appendTo($links) + + $links.find(".view-link") + .attr("data-doctype", item.doctype) + .click(function() { + wn.set_route("Form", $(this).attr("data-doctype")); + }) + } else if(item.type !== "Link"){ + $(' New \ + | \ + View \ + | \ + Import') + .appendTo($links) + + $links.find(".view-link") + .attr("data-doctype", item.doctype) + .click(function() { + if($(this).attr("data-filter")) { + wn.route_options = JSON.parse($(this).attr("data-filter")); + } + wn.set_route("List", $(this).attr("data-doctype")); + }) + + if(item.filter) + $links.find(".view-link").attr("data-filter", JSON.stringify(item.filter)) + + if(wn.model.can_create(item.doctype)) { + $links.find(".new-link") + .attr("data-doctype", item.doctype) + .click(function() { + new_doc($(this).attr("data-doctype")) + }) + } else { + $links.find(".new-link").remove(); + $links.find(".text-muted:first").remove(); + } + + } + + $links.find(".import-link") + .attr("data-doctype", item.doctype) + .click(function() { + wn.route_options = {doctype:$(this).attr("data-doctype")} + wn.set_route("data-import-tool"); + }) + + if(item.links) { + $.each(item.links, function(i, link) { + var newlinks = $(' | \ + '+link.title+'') + .appendTo($links) + }) + } + + if(item.dependencies) { + $.each(item.dependencies, function(i, d) { + render_item(d, true); + }) + } } } \ No newline at end of file diff --git a/setup/page/setup/setup.py b/setup/page/setup/setup.py new file mode 100644 index 00000000000..ab2cdb7384e --- /dev/null +++ b/setup/page/setup/setup.py @@ -0,0 +1,244 @@ +from __future__ import unicode_literals +import webnotes + +items = [ + { + "type": "Section", + "title": "Organization", + "icon": "icon-building" + }, + {"doctype":"Company"}, + {"doctype":"Fiscal Year"}, + {"doctype":"Currency"}, + { + "type": "Section", + "title": "Users and Permissions", + "icon": "icon-user" + }, + { + "doctype":"Profile", + }, + { + "doctype":"Role", + }, + { "title": "Permission Manager", + "route": "permission-manager", "type": "Link", "icon": "icon-shield" }, + { "title": "User Properties", + "route": "user-properties", "type": "Link", "icon": "icon-user" }, + { + "type": "Section", + "title": "Master Data", + "icon": "icon-star" + }, + { + "doctype": "Item", + "dependencies": [ + {"doctype":"Item Group", "tree": "Sales Browser"}, + {"doctype":"Warehouse"}, + {"doctype":"UOM"}, + {"doctype":"Brand"}, + {"doctype":"Price List"}, + ], + }, + { + "doctype": "Customer", + "dependencies": [ + {"doctype":"Customer Group", "tree": "Sales Browser"}, + {"doctype":"Territory", "tree": "Sales Browser"}, + {"doctype":"Sales Person", "tree": "Sales Browser"}, + {"doctype":"Contact"}, + {"doctype":"Address"}, + ] + }, + { + "doctype": "Supplier", + "dependencies": [ + {"doctype":"Supplier Type"}, + {"doctype":"Contact"}, + {"doctype":"Address"}, + ] + }, + { + "type": "Section", + "title": "Accounts", + "icon": "icon-money" + }, + { + "doctype": "Account", + "tree": "Accounts Browser", + "dependencies": [ + { + "title": "Bank Accounts", + "doctype":"Account", + "filter": {"account_type": "Bank or Cash"} + }, + { + "title": "Tax Accounts", + "doctype":"Account", + "filter": {"account_type": "Tax"} + }, + ] + }, + { + "doctype": "Cost Center", + "tree": "Accounts Browser", + }, + { "doctype": "Sales Taxes and Charges Master" }, + { "doctype": "Purchase Taxes and Charges Master" }, + { + "type": "Section", + "title": "Human Resource", + "icon": "icon-group" + }, + { + "doctype": "Employee", + "dependencies": [ + { "doctype": "Employment Type" }, + { "doctype": "Branch" }, + { "doctype": "Department" }, + { "doctype": "Designation" }, + { "doctype": "Holiday List" }, + { "doctype": "Grade" }, + ] + }, + { "doctype": "Salary Structure" }, + { "doctype": "Leave Allocation" }, + { "doctype": "Appraisal Template" }, + { + "type": "Section", + "title": "Printing", + "icon": "icon-print" + }, + { "doctype": "Letter Head" }, + { "doctype": "Print Heading" }, + { "doctype": "Print Format", "filter": {"standard": "No"} }, + { + "type": "Section", + "title": "Email", + "icon": "icon-envelope-alt" + }, + { + "title": "Outgoing Email Settings", + "doctype": "Email Settings", + "single": 1, + "query": "select count(*) from tabSingles where doctype='Email Settings' and field='outgoing_mail_server'" + }, + { + "doctype": "Support Email Settings", + "single": 1, + "query": "select count(*) from tabSingles where doctype='Email Settings' and field='support_host'" + }, + { + "doctype": "Sales Email Settings", + "single": 1, + "query": "select count(*) from tabSingles where doctype='Sales Email Settings' and field='host'" + }, + { + "doctype": "Jobs Email Settings", + "single": 1, + "query": "select count(*) from tabSingles where doctype='Jobs Email Settings' and field='host'" + }, + { + "doctype": "Email Digest", + }, + { + "doctype": "SMS Settings", + "single": 1, + "query": "select count(*) from tabSingles where doctype='SMS Settings' and field='sms_gateway_url'" + }, + { + "type": "Section", + "title": "Opening Accounts and Stock", + "icon": "icon-eye-open" + }, + { "doctype": "Stock Reconciliation" }, + { + "doctype": "Journal Voucher", + "title": "Opening Accounting Entries", + "filter": { + "is_opening": "Yes" + } + }, + { + "type": "Section", + "title": "Customization", + "icon": "icon-glass" + }, + { + "doctype": "Customize Form", + "single": 1, + "query": "select count(distinct doc_type) from `tabProperty Setter`" + }, + { "doctype": "Workflow" }, + { "doctype": "Authorization Rule" }, + { "doctype": "Custom Field" }, + { "doctype": "Custom Script" }, + { + "type": "Section", + "title": "Tools", + "icon": "icon-wrench" + }, + { "title": "Global Settings / Default Values", + "doctype": "Global Defaults", "single": 1, + "query": """select count(*) from tabSingles where doctype='Global Defaults' + and field not in ('owner', 'creation', 'modified', 'modified_by')"""}, + + { "title": "Show / Hide Features", + "doctype": "Features Setup", "single": 1, + "query": """select count(*) from tabSingles where doctype='Features Setup' + and field not in ('owner', 'creation', 'modified', 'modified_by')"""}, + + { "title": "Enable / Disable Email Notifications", + "doctype": "Notification Control", "single": 1, + "query": """select count(*) from tabSingles where doctype='Notification Control' + and field in ('quotation', 'sales_order', 'sales_invoice', 'purchase_order', 'purchase_receipt', 'expense_claim', 'delivery_note')"""}, + + { "doctype": "File Data", "title": "Uploaded File Attachments" }, + + { "title": "Data Import", + "route": "data-import-tool", "type": "Link", "icon": "icon-upload" }, + { "title": "Bulk Rename", + "route": "Form/Rename Tool", "type": "Link", "icon": "icon-upload" }, + { "title": "Update Numbering Series", + "route": "Form/Naming Series", "type": "Link", "icon": "icon-sort-by-order" }, + { "title": "Show / Hide Modules", + "route": "modules_setup", "type": "Link", "icon": "icon-th" }, + { "title": "Send Bulk SMS to Leads / Contacts", + "route": "Form/SMS Center", "type": "Link", "icon": "icon-mobile-phone" }, + { + "type": "Section", + "title": "System Administration", + "icon": "icon-cog" + }, + { "title": "Update ERPNext", + "route": "update-manager", "type": "Link", "icon": "icon-rss" }, + { "title": "Manage 3rd Party Backups", + "route": "Form/Backup Manager", "type": "Link", "icon": "icon-cloud" }, + { "title": "System Scheduler Errors", + "route": "Report/Scheduler Log", "type": "Link", "icon": "icon-exclamation-sign" }, +] + +@webnotes.whitelist(allow_roles=["System Manager"]) +def get(): + for item in items: + if item.get("type")=="Section": + continue + set_count(item) + + if item.get("dependencies"): + for d in item["dependencies"]: + set_count(d) + + return items + +def set_count(item): + if "query" in item: + item["count"] = webnotes.conn.sql(item["query"])[0][0] + elif "filter" in item: + key = item["filter"].keys()[0] + item["count"] = webnotes.conn.sql("""select count(*) from `tab%s` where + %s = %s""" % (item["doctype"], key, "%s"), + item["filter"][key])[0][0] + elif "doctype" in item: + item["count"] = webnotes.conn.sql("select count(*) from `tab%s`" \ + % item["doctype"])[0][0] diff --git a/startup/boot.py b/startup/boot.py index 7d5eb4e6ef8..a75c78ad5af 100644 --- a/startup/boot.py +++ b/startup/boot.py @@ -22,8 +22,12 @@ def boot_session(bootinfo): "Notification Control").get_values() # if no company, show a dialog box to create a new company - bootinfo['setup_complete'] = webnotes.conn.sql("""select name from - tabCompany limit 1""") and 'Yes' or 'No' + bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0] + + if not bootinfo["customer_count"]: + bootinfo['setup_complete'] = webnotes.conn.sql("""select name from + tabCompany limit 1""") and 'Yes' or 'No' + # load subscription info import conf diff --git a/startup/install.py b/startup/install.py index 205bee46e7b..89ab290d825 100644 --- a/startup/install.py +++ b/startup/install.py @@ -135,13 +135,7 @@ def import_defaults(): # supplier type {'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'}, - - # Price List - {'doctype': 'Price List', 'name': 'Default Price List', 'price_list_name': 'Default Price List', - "buying_or_selling": "Selling"}, - {'doctype': 'Price List', 'name': 'Standard', 'price_list_name': 'Standard', - "buying_or_selling": "Selling"}, - + # warehouse type {'doctype': 'Warehouse Type', 'name': 'Default Warehouse Type', 'warehouse_type': 'Default Warehouse Type'}, {'doctype': 'Warehouse Type', 'name': 'Fixed Asset', 'warehouse_type': 'Fixed Asset'},