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