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