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