blob: 581b53ddd919ee642f73b251b30e631b11617aba [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,
Abhishek Balam123eaea2020-09-18 16:30:50 +053021 "Issue": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053022 "Item": 5,
23 "Journal Entry": 3,
Abhishek Balam123eaea2020-09-18 16:30:50 +053024 "Lead": 3,
Abhishek Balam123eaea2020-09-18 16:30:50 +053025 "Material Request": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053026 "Opportunity": 5,
27 "Payment Entry": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053028 "Project": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053029 "Purchase Order": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053030 "Purchase Invoice": 5,
31 "Purchase Receipt": 5,
32 "Quotation": 3,
Ankush Menat4551d7d2021-08-19 13:41:10 +053033 "Sales Order": 2,
34 "Sales Invoice": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053035 "Stock Entry": 3,
Abhishek Balam123eaea2020-09-18 16:30:50 +053036 "Supplier": 5,
37 "Task": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053038 "User": 5,
Ankush Menat494bd9e2022-03-28 18:52:46 +053039 "Work Order": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053040 }
41
Ankush Menat8fe5feb2021-11-04 19:48:32 +053042 for doctype, min_count in doctypes.items():
Sahil Khan73e281d2019-05-09 14:32:15 +053043 count = frappe.db.count(doctype)
44 if count > min_count:
45 activation_level += 1
46 sales_data.append({doctype: count})
47
Ankush Menat494bd9e2022-03-28 18:52:46 +053048 if frappe.db.get_single_value("System Settings", "setup_complete"):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053049 activation_level += 1
50
Ankush Menat494bd9e2022-03-28 18:52:46 +053051 communication_number = frappe.db.count("Communication", dict(communication_medium="Email"))
Sahil Khan73e281d2019-05-09 14:32:15 +053052 if communication_number > 10:
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053053 activation_level += 1
Sahil Khan73e281d2019-05-09 14:32:15 +053054 sales_data.append({"Communication": communication_number})
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053055
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053056 # recent login
Ankush Menat494bd9e2022-03-28 18:52:46 +053057 if frappe.db.sql(
58 "select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1"
59 ):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053060 activation_level += 1
61
Sahil Khan73e281d2019-05-09 14:32:15 +053062 level = {"activation_level": activation_level, "sales_data": sales_data}
63
64 return level
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053065
Ankush Menat494bd9e2022-03-28 18:52:46 +053066
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053067def get_help_messages():
Ankush Menat494bd9e2022-03-28 18:52:46 +053068 """Returns help messages to be shown on Desktop"""
Rushabh Mehta7067ff02017-03-02 11:14:09 +053069 if get_level() > 6:
70 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053071
Ankush Menat494bd9e2022-03-28 18:52:46 +053072 domain = frappe.get_cached_value("Company", erpnext.get_default_company(), "domain")
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053073 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053074
Rushabh Mehtae7900b22017-03-02 11:13:18 +053075 message_settings = [
76 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +053077 doctype="Lead",
78 title=_("Create Leads"),
79 description=_("Leads help you get business, add all your contacts and more as your leads"),
80 action=_("Create Lead"),
81 route="List/Lead",
82 domain=("Manufacturing", "Retail", "Services", "Distribution"),
83 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +053084 ),
85 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +053086 doctype="Quotation",
87 title=_("Create customer quotes"),
88 description=_("Quotations are proposals, bids you have sent to your customers"),
89 action=_("Create Quotation"),
90 route="List/Quotation",
91 domain=("Manufacturing", "Retail", "Services", "Distribution"),
92 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +053093 ),
94 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +053095 doctype="Sales Order",
96 title=_("Manage your orders"),
97 description=_("Create Sales Orders to help you plan your work and deliver on-time"),
98 action=_("Create Sales Order"),
99 route="List/Sales Order",
100 domain=("Manufacturing", "Retail", "Services", "Distribution"),
101 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530102 ),
103 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530104 doctype="Purchase Order",
105 title=_("Create Purchase Orders"),
106 description=_("Purchase orders help you plan and follow up on your purchases"),
107 action=_("Create Purchase Order"),
108 route="List/Purchase Order",
109 domain=("Manufacturing", "Retail", "Services", "Distribution"),
110 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530111 ),
112 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530113 doctype="User",
114 title=_("Create Users"),
115 description=_(
116 "Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts"
117 ),
118 action=_("Create User"),
119 route="List/User",
120 domain=("Manufacturing", "Retail", "Services", "Distribution"),
121 target=3,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530122 ),
123 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530124 doctype="Timesheet",
125 title=_("Add Timesheets"),
126 description=_(
barredterra806696a2024-01-24 02:59:52 +0100127 "Timesheets help keep track of time, cost and billing for activities done by your team"
Ankush Menat494bd9e2022-03-28 18:52:46 +0530128 ),
129 action=_("Create Timesheet"),
130 route="List/Timesheet",
131 domain=("Services",),
132 target=5,
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530133 ),
134 frappe._dict(
Ankush Menat494bd9e2022-03-28 18:52:46 +0530135 doctype="Employee",
136 title=_("Create Employee Records"),
Rucha Mahabal7442a882022-07-01 10:34:32 +0530137 description=_("Create Employee records."),
Ankush Menat494bd9e2022-03-28 18:52:46 +0530138 action=_("Create Employee"),
139 route="List/Employee",
140 target=3,
141 ),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530142 ]
143
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530144 for m in message_settings:
145 if not m.domain or domain in m.domain:
146 m.count = frappe.db.count(m.doctype)
147 if m.count < m.target:
148 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530149
Nabin Haita2afc4e2017-02-27 15:39:29 +0530150 return messages