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 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 5 | import frappe |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 6 | from frappe import _ |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 7 | from six import iteritems |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 8 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 9 | import erpnext |
| 10 | |
| 11 | |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 12 | def get_level(): |
| 13 | activation_level = 0 |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 14 | sales_data = [] |
| 15 | min_count = 0 |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 16 | doctypes = { |
| 17 | "Asset": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 18 | "BOM": 3, |
| 19 | "Customer": 5, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 20 | "Delivery Note": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 21 | "Employee": 3, |
| 22 | "Instructor": 5, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 23 | "Issue": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 24 | "Item": 5, |
| 25 | "Journal Entry": 3, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 26 | "Lead": 3, |
| 27 | "Leave Application": 5, |
| 28 | "Material Request": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 29 | "Opportunity": 5, |
| 30 | "Payment Entry": 2, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 31 | "Project": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 32 | "Purchase Order": 2, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 33 | "Purchase Invoice": 5, |
| 34 | "Purchase Receipt": 5, |
| 35 | "Quotation": 3, |
| 36 | "Salary Slip": 5, |
| 37 | "Salary Structure": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 38 | "Sales Order": 2, |
| 39 | "Sales Invoice": 2, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 40 | "Stock Entry": 3, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 41 | "Student": 5, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 42 | "Supplier": 5, |
| 43 | "Task": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 44 | "User": 5, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 45 | "Work Order": 5 |
| 46 | } |
| 47 | |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 48 | for doctype, min_count in iteritems(doctypes): |
| 49 | count = frappe.db.count(doctype) |
| 50 | if count > min_count: |
| 51 | activation_level += 1 |
| 52 | sales_data.append({doctype: count}) |
| 53 | |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 54 | if frappe.db.get_single_value('System Settings', 'setup_complete'): |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 55 | activation_level += 1 |
| 56 | |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 57 | communication_number = frappe.db.count('Communication', dict(communication_medium='Email')) |
| 58 | if communication_number > 10: |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 59 | activation_level += 1 |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 60 | sales_data.append({"Communication": communication_number}) |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 61 | |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 62 | # recent login |
| 63 | if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'): |
| 64 | activation_level += 1 |
| 65 | |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 66 | level = {"activation_level": activation_level, "sales_data": sales_data} |
| 67 | |
| 68 | return level |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 69 | |
| 70 | def get_help_messages(): |
| 71 | '''Returns help messages to be shown on Desktop''' |
Rushabh Mehta | 7067ff0 | 2017-03-02 11:14:09 +0530 | [diff] [blame] | 72 | if get_level() > 6: |
| 73 | return [] |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 74 | |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 75 | domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain') |
Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 76 | messages = [] |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 77 | |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 78 | message_settings = [ |
| 79 | frappe._dict( |
| 80 | doctype='Lead', |
| 81 | title=_('Create Leads'), |
| 82 | 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] | 83 | action=_('Create Lead'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 84 | route='List/Lead', |
| 85 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 86 | target=3 |
| 87 | ), |
| 88 | frappe._dict( |
| 89 | doctype='Quotation', |
| 90 | title=_('Create customer quotes'), |
| 91 | description=_('Quotations are proposals, bids you have sent to your customers'), |
Suraj Shetty | b296500 | 2018-12-23 13:25:58 +0530 | [diff] [blame] | 92 | action=_('Create Quotation'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 93 | route='List/Quotation', |
| 94 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
Rushabh Mehta | 7067ff0 | 2017-03-02 11:14:09 +0530 | [diff] [blame] | 95 | target=3 |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 96 | ), |
| 97 | frappe._dict( |
| 98 | doctype='Sales Order', |
| 99 | title=_('Manage your orders'), |
Suraj Shetty | b296500 | 2018-12-23 13:25:58 +0530 | [diff] [blame] | 100 | description=_('Create Sales Orders to help you plan your work and deliver on-time'), |
| 101 | action=_('Create Sales Order'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 102 | route='List/Sales Order', |
| 103 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 104 | target=3 |
| 105 | ), |
| 106 | frappe._dict( |
| 107 | doctype='Purchase Order', |
| 108 | title=_('Create Purchase Orders'), |
| 109 | description=_('Purchase orders help you plan and follow up on your purchases'), |
Suraj Shetty | b296500 | 2018-12-23 13:25:58 +0530 | [diff] [blame] | 110 | action=_('Create Purchase Order'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 111 | route='List/Purchase Order', |
| 112 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 113 | target=3 |
| 114 | ), |
| 115 | frappe._dict( |
| 116 | doctype='User', |
| 117 | title=_('Create Users'), |
| 118 | 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] | 119 | action=_('Create User'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 120 | route='List/User', |
| 121 | domain=('Manufacturing', 'Retail', 'Services', 'Distribution'), |
| 122 | target=3 |
| 123 | ), |
| 124 | frappe._dict( |
| 125 | doctype='Timesheet', |
| 126 | title=_('Add Timesheets'), |
| 127 | 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] | 128 | action=_('Create Timesheet'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 129 | route='List/Timesheet', |
| 130 | domain=('Services',), |
| 131 | target=5 |
| 132 | ), |
| 133 | frappe._dict( |
| 134 | doctype='Student', |
| 135 | title=_('Add Students'), |
| 136 | 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] | 137 | action=_('Create Student'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 138 | route='List/Student', |
| 139 | domain=('Education',), |
| 140 | target=5 |
| 141 | ), |
| 142 | frappe._dict( |
| 143 | doctype='Student Batch', |
| 144 | title=_('Group your students in batches'), |
| 145 | description=_('Student Batches help you track attendance, assessments and fees for students'), |
Suraj Shetty | b296500 | 2018-12-23 13:25:58 +0530 | [diff] [blame] | 146 | action=_('Create Student Batch'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 147 | route='List/Student Batch', |
| 148 | domain=('Education',), |
| 149 | target=3 |
| 150 | ), |
| 151 | frappe._dict( |
| 152 | doctype='Employee', |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 153 | title=_('Create Employee Records'), |
| 154 | description=_('Create Employee records to manage leaves, expense claims and payroll'), |
Suraj Shetty | b296500 | 2018-12-23 13:25:58 +0530 | [diff] [blame] | 155 | action=_('Create Employee'), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 156 | route='List/Employee', |
| 157 | target=3 |
| 158 | ) |
| 159 | ] |
| 160 | |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 161 | for m in message_settings: |
| 162 | if not m.domain or domain in m.domain: |
| 163 | m.count = frappe.db.count(m.doctype) |
| 164 | if m.count < m.target: |
| 165 | messages.append(m) |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 166 | |
Nabin Hait | a2afc4e | 2017-02-27 15:39:29 +0530 | [diff] [blame] | 167 | return messages |