blob: 8ccda4111790e7285c20c7198a03b92e941ff5e4 [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 _
Sahil Khan73e281d2019-05-09 14:32:15 +05307from six import iteritems
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05308
Chillar Anand915b3432021-09-02 16:44:59 +05309import erpnext
10
11
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053012def get_level():
13 activation_level = 0
Sahil Khan73e281d2019-05-09 14:32:15 +053014 sales_data = []
15 min_count = 0
Abhishek Balam123eaea2020-09-18 16:30:50 +053016 doctypes = {
17 "Asset": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053018 "BOM": 3,
19 "Customer": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053020 "Delivery Note": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053021 "Employee": 3,
22 "Instructor": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053023 "Issue": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053024 "Item": 5,
25 "Journal Entry": 3,
Abhishek Balam123eaea2020-09-18 16:30:50 +053026 "Lead": 3,
27 "Leave Application": 5,
28 "Material Request": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053029 "Opportunity": 5,
30 "Payment Entry": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053031 "Project": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053032 "Purchase Order": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053033 "Purchase Invoice": 5,
34 "Purchase Receipt": 5,
35 "Quotation": 3,
36 "Salary Slip": 5,
37 "Salary Structure": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053038 "Sales Order": 2,
39 "Sales Invoice": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053040 "Stock Entry": 3,
Ankush Menat4551d7d2021-08-19 13:41:10 +053041 "Student": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053042 "Supplier": 5,
43 "Task": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053044 "User": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053045 "Work Order": 5
46 }
47
Sahil Khan73e281d2019-05-09 14:32:15 +053048 for doctype, min_count in iteritems(doctypes):
49 count = frappe.db.count(doctype)
50 if count > min_count:
51 activation_level += 1
52 sales_data.append({doctype: count})
53
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053054 if frappe.db.get_single_value('System Settings', 'setup_complete'):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053055 activation_level += 1
56
Sahil Khan73e281d2019-05-09 14:32:15 +053057 communication_number = frappe.db.count('Communication', dict(communication_medium='Email'))
58 if communication_number > 10:
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053059 activation_level += 1
Sahil Khan73e281d2019-05-09 14:32:15 +053060 sales_data.append({"Communication": communication_number})
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053061
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053062 # recent login
63 if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
64 activation_level += 1
65
Sahil Khan73e281d2019-05-09 14:32:15 +053066 level = {"activation_level": activation_level, "sales_data": sales_data}
67
68 return level
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053069
70def get_help_messages():
71 '''Returns help messages to be shown on Desktop'''
Rushabh Mehta7067ff02017-03-02 11:14:09 +053072 if get_level() > 6:
73 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053074
Rushabh Mehta708e47a2018-08-08 16:37:31 +053075 domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain')
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053076 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053077
Rushabh Mehtae7900b22017-03-02 11:13:18 +053078 message_settings = [
79 frappe._dict(
80 doctype='Lead',
81 title=_('Create Leads'),
82 description=_('Leads help you get business, add all your contacts and more as your leads'),
Suraj Shettyb2965002018-12-23 13:25:58 +053083 action=_('Create Lead'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053084 route='List/Lead',
85 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
86 target=3
87 ),
88 frappe._dict(
89 doctype='Quotation',
90 title=_('Create customer quotes'),
91 description=_('Quotations are proposals, bids you have sent to your customers'),
Suraj Shettyb2965002018-12-23 13:25:58 +053092 action=_('Create Quotation'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053093 route='List/Quotation',
94 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
Rushabh Mehta7067ff02017-03-02 11:14:09 +053095 target=3
Rushabh Mehtae7900b22017-03-02 11:13:18 +053096 ),
97 frappe._dict(
98 doctype='Sales Order',
99 title=_('Manage your orders'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530100 description=_('Create Sales Orders to help you plan your work and deliver on-time'),
101 action=_('Create Sales Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530102 route='List/Sales Order',
103 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
104 target=3
105 ),
106 frappe._dict(
107 doctype='Purchase Order',
108 title=_('Create Purchase Orders'),
109 description=_('Purchase orders help you plan and follow up on your purchases'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530110 action=_('Create Purchase Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530111 route='List/Purchase Order',
112 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
113 target=3
114 ),
115 frappe._dict(
116 doctype='User',
117 title=_('Create Users'),
118 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 Shettyb2965002018-12-23 13:25:58 +0530119 action=_('Create User'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530120 route='List/User',
121 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
122 target=3
123 ),
124 frappe._dict(
125 doctype='Timesheet',
126 title=_('Add Timesheets'),
127 description=_('Timesheets help keep track of time, cost and billing for activites done by your team'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530128 action=_('Create Timesheet'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530129 route='List/Timesheet',
130 domain=('Services',),
131 target=5
132 ),
133 frappe._dict(
134 doctype='Student',
135 title=_('Add Students'),
136 description=_('Students are at the heart of the system, add all your students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530137 action=_('Create Student'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530138 route='List/Student',
139 domain=('Education',),
140 target=5
141 ),
142 frappe._dict(
143 doctype='Student Batch',
144 title=_('Group your students in batches'),
145 description=_('Student Batches help you track attendance, assessments and fees for students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530146 action=_('Create Student Batch'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530147 route='List/Student Batch',
148 domain=('Education',),
149 target=3
150 ),
151 frappe._dict(
152 doctype='Employee',
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530153 title=_('Create Employee Records'),
154 description=_('Create Employee records to manage leaves, expense claims and payroll'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530155 action=_('Create Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530156 route='List/Employee',
157 target=3
158 )
159 ]
160
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530161 for m in message_settings:
162 if not m.domain or domain in m.domain:
163 m.count = frappe.db.count(m.doctype)
164 if m.count < m.target:
165 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530166
Nabin Haita2afc4e2017-02-27 15:39:29 +0530167 return messages