From 05ce7ec7bb238c177e313765d357dd636eab6b70 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 22 Feb 2017 16:15:43 +0530 Subject: [PATCH] [enhance] desktop messages --- erpnext/hooks.py | 1 + erpnext/utilities/activation.py | 105 +++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 95f6c0b5c4..af364e857f 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -28,6 +28,7 @@ after_install = "erpnext.setup.install.after_install" boot_session = "erpnext.startup.boot.boot_session" notification_config = "erpnext.startup.notifications.get_notification_config" +get_help_messages = "erpnext.utilities.activation.get_help_messages" on_session_creation = "erpnext.shopping_cart.utils.set_cart_count" on_logout = "erpnext.shopping_cart.utils.clear_cart_count" diff --git a/erpnext/utilities/activation.py b/erpnext/utilities/activation.py index 563f71ea2b..eec3973ddb 100644 --- a/erpnext/utilities/activation.py +++ b/erpnext/utilities/activation.py @@ -1,4 +1,6 @@ -import frappe +import frappe, erpnext + +from frappe import _ def get_level(): activation_level = 0 @@ -20,6 +22,9 @@ def get_level(): if frappe.db.count('Employee') > 3: activation_level += 1 + if frappe.db.count('Lead') > 3: + activation_level += 1 + if frappe.db.count('Payment Entry') > 2: activation_level += 1 @@ -29,8 +34,104 @@ def get_level(): if frappe.db.count('User') > 5: activation_level += 1 + if frappe.db.count('Student') > 5: + activation_level += 1 + + if frappe.db.count('Student Batch') > 5: + activation_level += 1 + + if frappe.db.count('Instructor') > 5: + activation_level += 1 + # recent login if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'): activation_level += 1 - return activation_level \ No newline at end of file + return activation_level + +def get_help_messages(): + '''Returns help messages to be shown on Desktop''' + # if get_level() > 6: + # return [] + + messages = [] + + domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') + + if domain in ('Manufacturing', 'Retail', 'Services', 'Distribution'): + count = frappe.db.count('Lead') + if count < 3: + messages.append(dict( + title=_('Create Leads'), + description=_('Create Leads'), + action=_('Leads help you get business, add all your contacts and more as your leads'), + route='List/Lead', + count=count + )) + + count = frappe.db.count('Quotation') + if count < 3: + messages.append(dict( + title=_('Create customer quotes'), + description=_('Quotations are proposals, bids you have sent to your customers'), + action=_('Make Quotation'), + route='List/Quotation' + )) + + count = frappe.db.count('Sales Order') + if count < 3: + messages.append(dict( + title=_('Manage your orders'), + description=_('Make Sales Orders to help you plan your work and deliver on-time'), + action=_('Make Sales Order'), + route='List/Sales Order' + )) + + count = frappe.db.count('Purchase Order') + if count < 3: + messages.append(dict( + title=_('Create Purchase Orders'), + description=_('Purchase orders help you plan and follow up on your purchases'), + action=_('Make Purchase Order'), + route='List/Purchase Order' + )) + + count = frappe.db.count('User') + if count < 3: + messages.append(dict( + title=_('Create Users'), + description=_('Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts'), + action=_('Make User'), + route='List/User' + )) + + elif domain == 'Education': + count = frappe.db.count('Student') + if count < 5: + messages.append(dict( + title=_('Add Students'), + description=_('Students are at the heart of the system, add all your students'), + action=_('Make Student'), + route='List/Student' + )) + + count = frappe.db.count('Student Batch') + if count < 3: + messages.append(dict( + title=_('Group your students in batches'), + description=_('Student Batches help you track attendance, assessments and fees for students'), + action=_('Make Student Batch'), + route='List/Student Batch' + )) + + # anyways + count = frappe.db.count('Employee') + if count < 3: + messages.append(dict( + title=_('Create Employee Records'), + description=_('Create Employee records to manage leaves, expense claims and payroll'), + action=_('Make Employee'), + route='List/Employee' + )) + + return messages \ No newline at end of file