blob: 43af0dc3c1b7a187a23f7e42441999b19b4dfd40 [file] [log] [blame]
Prateeksha Singh95d8fd32017-09-04 11:14:04 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +05304
Chillar Anand915b3432021-09-02 16:44:59 +05305import frappe
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +05306from frappe import _
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05307
Chillar Anand915b3432021-09-02 16:44:59 +05308import erpnext
9
10
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053011def get_level():
12 activation_level = 0
Sahil Khan73e281d2019-05-09 14:32:15 +053013 sales_data = []
14 min_count = 0
Abhishek Balam123eaea2020-09-18 16:30:50 +053015 doctypes = {
16 "Asset": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053017 "BOM": 3,
18 "Customer": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053019 "Delivery Note": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053020 "Employee": 3,
21 "Instructor": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053022 "Issue": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053023 "Item": 5,
24 "Journal Entry": 3,
Abhishek Balam123eaea2020-09-18 16:30:50 +053025 "Lead": 3,
26 "Leave Application": 5,
27 "Material Request": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053028 "Opportunity": 5,
29 "Payment Entry": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053030 "Project": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053031 "Purchase Order": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053032 "Purchase Invoice": 5,
33 "Purchase Receipt": 5,
34 "Quotation": 3,
35 "Salary Slip": 5,
36 "Salary Structure": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053037 "Sales Order": 2,
38 "Sales Invoice": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053039 "Stock Entry": 3,
Ankush Menat4551d7d2021-08-19 13:41:10 +053040 "Student": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053041 "Supplier": 5,
42 "Task": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053043 "User": 5,
Ankush Menat494bd9e2022-03-28 18:52:46 +053044 "Work Order": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053045 }
46
Ankush Menat8fe5feb2021-11-04 19:48:32 +053047 for doctype, min_count in doctypes.items():
Sahil Khan73e281d2019-05-09 14:32:15 +053048 count = frappe.db.count(doctype)
49 if count > min_count:
50 activation_level += 1
51 sales_data.append({doctype: count})
52
Ankush Menat494bd9e2022-03-28 18:52:46 +053053 if frappe.db.get_single_value("System Settings", "setup_complete"):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053054 activation_level += 1
55
Ankush Menat494bd9e2022-03-28 18:52:46 +053056 communication_number = frappe.db.count("Communication", dict(communication_medium="Email"))
Sahil Khan73e281d2019-05-09 14:32:15 +053057 if communication_number > 10:
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053058 activation_level += 1
Sahil Khan73e281d2019-05-09 14:32:15 +053059 sales_data.append({"Communication": communication_number})
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053060
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053061 # recent login
Ankush Menat494bd9e2022-03-28 18:52:46 +053062 if frappe.db.sql(
63 "select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1"
64 ):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053065 activation_level += 1
66
Sahil Khan73e281d2019-05-09 14:32:15 +053067 level = {"activation_level": activation_level, "sales_data": sales_data}
68
69 return level
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053070
Ankush Menat494bd9e2022-03-28 18:52:46 +053071
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053072def get_help_messages():
Ankush Menat494bd9e2022-03-28 18:52:46 +053073 """Returns help messages to be shown on Desktop"""
Rushabh Mehta7067ff02017-03-02 11:14:09 +053074 if get_level() > 6:
75 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053076
Ankush Menat494bd9e2022-03-28 18:52:46 +053077 domain = frappe.get_cached_value("Company", erpnext.get_default_company(), "domain")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053078 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053079
Rushabh Mehtae7900b22017-03-02 11:13:18 +053080 message_settings = [
81 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +053082 doctype="Lead",
83 title=_("Create Leads"),
84 description=_("Leads help you get business, add all your contacts and more as your leads"),
85 action=_("Create Lead"),
86 route="List/Lead",
87 domain=("Manufacturing", "Retail", "Services", "Distribution"),
88 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +053089 ),
90 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +053091 doctype="Quotation",
92 title=_("Create customer quotes"),
93 description=_("Quotations are proposals, bids you have sent to your customers"),
94 action=_("Create Quotation"),
95 route="List/Quotation",
96 domain=("Manufacturing", "Retail", "Services", "Distribution"),
97 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +053098 ),
99 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530100 doctype="Sales Order",
101 title=_("Manage your orders"),
102 description=_("Create Sales Orders to help you plan your work and deliver on-time"),
103 action=_("Create Sales Order"),
104 route="List/Sales Order",
105 domain=("Manufacturing", "Retail", "Services", "Distribution"),
106 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530107 ),
108 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530109 doctype="Purchase Order",
110 title=_("Create Purchase Orders"),
111 description=_("Purchase orders help you plan and follow up on your purchases"),
112 action=_("Create Purchase Order"),
113 route="List/Purchase Order",
114 domain=("Manufacturing", "Retail", "Services", "Distribution"),
115 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530116 ),
117 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530118 doctype="User",
119 title=_("Create Users"),
120 description=_(
121 "Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts"
122 ),
123 action=_("Create User"),
124 route="List/User",
125 domain=("Manufacturing", "Retail", "Services", "Distribution"),
126 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530127 ),
128 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530129 doctype="Timesheet",
130 title=_("Add Timesheets"),
131 description=_(
132 "Timesheets help keep track of time, cost and billing for activites done by your team"
133 ),
134 action=_("Create Timesheet"),
135 route="List/Timesheet",
136 domain=("Services",),
137 target=5,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530138 ),
139 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530140 doctype="Student",
141 title=_("Add Students"),
142 description=_("Students are at the heart of the system, add all your students"),
143 action=_("Create Student"),
144 route="List/Student",
145 domain=("Education",),
146 target=5,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530147 ),
148 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530149 doctype="Student Batch",
150 title=_("Group your students in batches"),
151 description=_("Student Batches help you track attendance, assessments and fees for students"),
152 action=_("Create Student Batch"),
153 route="List/Student Batch",
154 domain=("Education",),
155 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530156 ),
157 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530158 doctype="Employee",
159 title=_("Create Employee Records"),
160 description=_("Create Employee records to manage leaves, expense claims and payroll"),
161 action=_("Create Employee"),
162 route="List/Employee",
163 target=3,
164 ),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530165 ]
166
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530167 for m in message_settings:
168 if not m.domain or domain in m.domain:
169 m.count = frappe.db.count(m.doctype)
170 if m.count < m.target:
171 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530172
Nabin Haita2afc4e2017-02-27 15:39:29 +0530173 return messages