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