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