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, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 21 | "Issue": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 22 | "Item": 5, |
| 23 | "Journal Entry": 3, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 24 | "Lead": 3, |
| 25 | "Leave Application": 5, |
| 26 | "Material Request": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 27 | "Opportunity": 5, |
| 28 | "Payment Entry": 2, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 29 | "Project": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 30 | "Purchase Order": 2, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 31 | "Purchase Invoice": 5, |
| 32 | "Purchase Receipt": 5, |
| 33 | "Quotation": 3, |
| 34 | "Salary Slip": 5, |
| 35 | "Salary Structure": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 36 | "Sales Order": 2, |
| 37 | "Sales Invoice": 2, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 38 | "Stock Entry": 3, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 39 | "Supplier": 5, |
| 40 | "Task": 5, |
Ankush Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 41 | "User": 5, |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 42 | "Work Order": 5, |
Abhishek Balam | 123eaea | 2020-09-18 16:30:50 +0530 | [diff] [blame] | 43 | } |
| 44 | |
Ankush Menat | 8fe5feb | 2021-11-04 19:48:32 +0530 | [diff] [blame] | 45 | for doctype, min_count in doctypes.items(): |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 46 | count = frappe.db.count(doctype) |
| 47 | if count > min_count: |
| 48 | activation_level += 1 |
| 49 | sales_data.append({doctype: count}) |
| 50 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 51 | if frappe.db.get_single_value("System Settings", "setup_complete"): |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 52 | activation_level += 1 |
| 53 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 54 | communication_number = frappe.db.count("Communication", dict(communication_medium="Email")) |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 55 | if communication_number > 10: |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 56 | activation_level += 1 |
Sahil Khan | 73e281d | 2019-05-09 14:32:15 +0530 | [diff] [blame] | 57 | sales_data.append({"Communication": communication_number}) |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 58 | |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 59 | # recent login |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 60 | if frappe.db.sql( |
| 61 | "select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1" |
| 62 | ): |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 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 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 69 | |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 70 | def get_help_messages(): |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 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 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +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( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 80 | doctype="Lead", |
| 81 | title=_("Create Leads"), |
| 82 | description=_("Leads help you get business, add all your contacts and more as your leads"), |
| 83 | action=_("Create Lead"), |
| 84 | route="List/Lead", |
| 85 | domain=("Manufacturing", "Retail", "Services", "Distribution"), |
| 86 | target=3, |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 87 | ), |
| 88 | frappe._dict( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 89 | doctype="Quotation", |
| 90 | title=_("Create customer quotes"), |
| 91 | description=_("Quotations are proposals, bids you have sent to your customers"), |
| 92 | action=_("Create Quotation"), |
| 93 | route="List/Quotation", |
| 94 | domain=("Manufacturing", "Retail", "Services", "Distribution"), |
| 95 | target=3, |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 96 | ), |
| 97 | frappe._dict( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 98 | doctype="Sales Order", |
| 99 | title=_("Manage your orders"), |
| 100 | description=_("Create Sales Orders to help you plan your work and deliver on-time"), |
| 101 | action=_("Create Sales Order"), |
| 102 | route="List/Sales Order", |
| 103 | domain=("Manufacturing", "Retail", "Services", "Distribution"), |
| 104 | target=3, |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 105 | ), |
| 106 | frappe._dict( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 107 | doctype="Purchase Order", |
| 108 | title=_("Create Purchase Orders"), |
| 109 | description=_("Purchase orders help you plan and follow up on your purchases"), |
| 110 | action=_("Create Purchase Order"), |
| 111 | route="List/Purchase Order", |
| 112 | domain=("Manufacturing", "Retail", "Services", "Distribution"), |
| 113 | target=3, |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 114 | ), |
| 115 | frappe._dict( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 116 | doctype="User", |
| 117 | title=_("Create Users"), |
| 118 | description=_( |
| 119 | "Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts" |
| 120 | ), |
| 121 | action=_("Create User"), |
| 122 | route="List/User", |
| 123 | domain=("Manufacturing", "Retail", "Services", "Distribution"), |
| 124 | target=3, |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 125 | ), |
| 126 | frappe._dict( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 127 | doctype="Timesheet", |
| 128 | title=_("Add Timesheets"), |
| 129 | description=_( |
| 130 | "Timesheets help keep track of time, cost and billing for activites done by your team" |
| 131 | ), |
| 132 | action=_("Create Timesheet"), |
| 133 | route="List/Timesheet", |
| 134 | domain=("Services",), |
| 135 | target=5, |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 136 | ), |
| 137 | frappe._dict( |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 138 | doctype="Employee", |
| 139 | title=_("Create Employee Records"), |
| 140 | description=_("Create Employee records to manage leaves, expense claims and payroll"), |
| 141 | action=_("Create Employee"), |
| 142 | route="List/Employee", |
| 143 | target=3, |
| 144 | ), |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 145 | ] |
| 146 | |
Rushabh Mehta | e7900b2 | 2017-03-02 11:13:18 +0530 | [diff] [blame] | 147 | for m in message_settings: |
| 148 | if not m.domain or domain in m.domain: |
| 149 | m.count = frappe.db.count(m.doctype) |
| 150 | if m.count < m.target: |
| 151 | messages.append(m) |
Rushabh Mehta | 05ce7ec | 2017-02-22 16:15:43 +0530 | [diff] [blame] | 152 | |
Nabin Hait | a2afc4e | 2017-02-27 15:39:29 +0530 | [diff] [blame] | 153 | return messages |