Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 4 | import frappe, erpnext |
| 5 | |
| 6 | from frappe import _ |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 7 | |
| 8 | def get_level(): |
| 9 | activation_level = 0 |
| 10 | if frappe.db.get_single_value('System Settings', 'setup_complete'): |
| 11 | activation_level = 1 |
| 12 | |
| 13 | if frappe.db.count('Item') > 5: |
| 14 | activation_level += 1 |
| 15 | |
| 16 | if frappe.db.count('Customer') > 5: |
| 17 | activation_level += 1 |
| 18 | |
| 19 | if frappe.db.count('Sales Order') > 2: |
| 20 | activation_level += 1 |
| 21 | |
| 22 | if frappe.db.count('Purchase Order') > 2: |
| 23 | activation_level += 1 |
| 24 | |
| 25 | if frappe.db.count('Employee') > 3: |
| 26 | activation_level += 1 |
| 27 | |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 28 | if frappe.db.count('Lead') > 3: |
| 29 | activation_level += 1 |
| 30 | |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 31 | if frappe.db.count('Payment Entry') > 2: |
| 32 | activation_level += 1 |
| 33 | |
| 34 | if frappe.db.count('Communication', dict(communication_medium='Email')) > 10: |
| 35 | activation_level += 1 |
| 36 | |
| 37 | if frappe.db.count('User') > 5: |
| 38 | activation_level += 1 |
| 39 | |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 40 | if frappe.db.count('Student') > 5: |
| 41 | activation_level += 1 |
| 42 | |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 43 | if frappe.db.count('Instructor') > 5: |
| 44 | activation_level += 1 |
| 45 | |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 46 | # recent login |
| 47 | if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'): |
| 48 | activation_level += 1 |
| 49 | |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 50 | return activation_level |
| 51 | |
| 52 | def get_help_messages(): |
| 53 | '''Returns help messages to be shown on Desktop''' |
Rushabh Mehta | 7067ff0 | 2017-03-02 11:14:09 +0530 | [diff] [blame] | 54 | if get_level() > 6: |
| 55 | return [] |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 56 | |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 57 | domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain') |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 58 | messages = [] |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 59 | |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 60 | message_settings = [ |
| 61 | frappe._dict( |
| 62 | doctype='Lead', |
| 63 | title=_('Create Leads'), |
| 64 | description=_('Leads help you get business, add all your contacts and more as your leads'), |
| 65 | action=_('Make Lead'), |
| 66 | route='List/Lead', |
| 67 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 68 | target=3 |
| 69 | ), |
| 70 | frappe._dict( |
| 71 | doctype='Quotation', |
| 72 | title=_('Create customer quotes'), |
| 73 | description=_('Quotations are proposals, bids you have sent to your customers'), |
| 74 | action=_('Make Quotation'), |
| 75 | route='List/Quotation', |
| 76 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
Rushabh Mehta | 7067ff0 | 2017-03-02 11:14:09 +0530 | [diff] [blame] | 77 | target=3 |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 78 | ), |
| 79 | frappe._dict( |
| 80 | doctype='Sales Order', |
| 81 | title=_('Manage your orders'), |
| 82 | description=_('Make Sales Orders to help you plan your work and deliver on-time'), |
| 83 | action=_('Make Sales Order'), |
| 84 | route='List/Sales Order', |
| 85 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 86 | target=3 |
| 87 | ), |
| 88 | frappe._dict( |
| 89 | doctype='Purchase Order', |
| 90 | title=_('Create Purchase Orders'), |
| 91 | description=_('Purchase orders help you plan and follow up on your purchases'), |
| 92 | action=_('Make Purchase Order'), |
| 93 | route='List/Purchase Order', |
| 94 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 95 | target=3 |
| 96 | ), |
| 97 | frappe._dict( |
| 98 | doctype='User', |
| 99 | title=_('Create Users'), |
| 100 | description=_('Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts'), |
| 101 | action=_('Make User'), |
| 102 | route='List/User', |
| 103 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 104 | target=3 |
| 105 | ), |
| 106 | frappe._dict( |
| 107 | doctype='Timesheet', |
| 108 | title=_('Add Timesheets'), |
| 109 | description=_('Timesheets help keep track of time, cost and billing for activites done by your team'), |
| 110 | action=_('Make Timesheet'), |
| 111 | route='List/Timesheet', |
| 112 | domain=('Services',), |
| 113 | target=5 |
| 114 | ), |
| 115 | frappe._dict( |
| 116 | doctype='Student', |
| 117 | title=_('Add Students'), |
| 118 | description=_('Students are at the heart of the system, add all your students'), |
| 119 | action=_('Make Student'), |
| 120 | route='List/Student', |
| 121 | domain=('Education',), |
| 122 | target=5 |
| 123 | ), |
| 124 | frappe._dict( |
| 125 | doctype='Student Batch', |
| 126 | title=_('Group your students in batches'), |
| 127 | description=_('Student Batches help you track attendance, assessments and fees for students'), |
| 128 | action=_('Make Student Batch'), |
| 129 | route='List/Student Batch', |
| 130 | domain=('Education',), |
| 131 | target=3 |
| 132 | ), |
| 133 | frappe._dict( |
| 134 | doctype='Employee', |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 135 | title=_('Create Employee Records'), |
| 136 | description=_('Create Employee records to manage leaves, expense claims and payroll'), |
| 137 | action=_('Make Employee'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 138 | route='List/Employee', |
| 139 | target=3 |
| 140 | ) |
| 141 | ] |
| 142 | |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 143 | for m in message_settings: |
| 144 | if not m.domain or domain in m.domain: |
| 145 | m.count = frappe.db.count(m.doctype) |
| 146 | if m.count < m.target: |
| 147 | messages.append(m) |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 148 | |
Nabin Hait | a2afc4e | 2017-02-27 15:39:29 +0530 | [diff] [blame] | 149 | return messages |