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