blob: c21bff0b252baabe4a36d6969f847f9e17c44d69 [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
Aditya Hasef3c22f32019-01-22 18:22:20 +05304from __future__ import unicode_literals
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +05305
Chillar Anand915b3432021-09-02 16:44:59 +05306import frappe
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +05307from frappe import _
Sahil Khan73e281d2019-05-09 14:32:15 +05308from six import iteritems
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05309
Chillar Anand915b3432021-09-02 16:44:59 +053010import erpnext
11
12
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053013def get_level():
14 activation_level = 0
Sahil Khan73e281d2019-05-09 14:32:15 +053015 sales_data = []
16 min_count = 0
Abhishek Balam123eaea2020-09-18 16:30:50 +053017 doctypes = {
18 "Asset": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053019 "BOM": 3,
20 "Customer": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053021 "Delivery Note": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053022 "Employee": 3,
23 "Instructor": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053024 "Issue": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053025 "Item": 5,
26 "Journal Entry": 3,
Abhishek Balam123eaea2020-09-18 16:30:50 +053027 "Lead": 3,
28 "Leave Application": 5,
29 "Material Request": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053030 "Opportunity": 5,
31 "Payment Entry": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053032 "Project": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053033 "Purchase Order": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053034 "Purchase Invoice": 5,
35 "Purchase Receipt": 5,
36 "Quotation": 3,
37 "Salary Slip": 5,
38 "Salary Structure": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053039 "Sales Order": 2,
40 "Sales Invoice": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053041 "Stock Entry": 3,
Ankush Menat4551d7d2021-08-19 13:41:10 +053042 "Student": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053043 "Supplier": 5,
44 "Task": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053045 "User": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053046 "Work Order": 5
47 }
48
Sahil Khan73e281d2019-05-09 14:32:15 +053049 for doctype, min_count in iteritems(doctypes):
50 count = frappe.db.count(doctype)
51 if count > min_count:
52 activation_level += 1
53 sales_data.append({doctype: count})
54
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053055 if frappe.db.get_single_value('System Settings', 'setup_complete'):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053056 activation_level += 1
57
Sahil Khan73e281d2019-05-09 14:32:15 +053058 communication_number = frappe.db.count('Communication', dict(communication_medium='Email'))
59 if communication_number > 10:
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053060 activation_level += 1
Sahil Khan73e281d2019-05-09 14:32:15 +053061 sales_data.append({"Communication": communication_number})
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053062
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053063 # recent login
64 if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
65 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
71def get_help_messages():
72 '''Returns help messages to be shown on Desktop'''
Rushabh Mehta7067ff02017-03-02 11:14:09 +053073 if get_level() > 6:
74 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053075
Rushabh Mehta708e47a2018-08-08 16:37:31 +053076 domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain')
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053077 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053078
Rushabh Mehtae7900b22017-03-02 11:13:18 +053079 message_settings = [
80 frappe._dict(
81 doctype='Lead',
82 title=_('Create Leads'),
83 description=_('Leads help you get business, add all your contacts and more as your leads'),
Suraj Shettyb2965002018-12-23 13:25:58 +053084 action=_('Create Lead'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053085 route='List/Lead',
86 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
87 target=3
88 ),
89 frappe._dict(
90 doctype='Quotation',
91 title=_('Create customer quotes'),
92 description=_('Quotations are proposals, bids you have sent to your customers'),
Suraj Shettyb2965002018-12-23 13:25:58 +053093 action=_('Create Quotation'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053094 route='List/Quotation',
95 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
Rushabh Mehta7067ff02017-03-02 11:14:09 +053096 target=3
Rushabh Mehtae7900b22017-03-02 11:13:18 +053097 ),
98 frappe._dict(
99 doctype='Sales Order',
100 title=_('Manage your orders'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530101 description=_('Create Sales Orders to help you plan your work and deliver on-time'),
102 action=_('Create Sales Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530103 route='List/Sales Order',
104 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
105 target=3
106 ),
107 frappe._dict(
108 doctype='Purchase Order',
109 title=_('Create Purchase Orders'),
110 description=_('Purchase orders help you plan and follow up on your purchases'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530111 action=_('Create Purchase Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530112 route='List/Purchase Order',
113 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
114 target=3
115 ),
116 frappe._dict(
117 doctype='User',
118 title=_('Create Users'),
119 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 +0530120 action=_('Create User'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530121 route='List/User',
122 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
123 target=3
124 ),
125 frappe._dict(
126 doctype='Timesheet',
127 title=_('Add Timesheets'),
128 description=_('Timesheets help keep track of time, cost and billing for activites done by your team'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530129 action=_('Create Timesheet'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530130 route='List/Timesheet',
131 domain=('Services',),
132 target=5
133 ),
134 frappe._dict(
135 doctype='Student',
136 title=_('Add Students'),
137 description=_('Students are at the heart of the system, add all your students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530138 action=_('Create Student'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530139 route='List/Student',
140 domain=('Education',),
141 target=5
142 ),
143 frappe._dict(
144 doctype='Student Batch',
145 title=_('Group your students in batches'),
146 description=_('Student Batches help you track attendance, assessments and fees for students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530147 action=_('Create Student Batch'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530148 route='List/Student Batch',
149 domain=('Education',),
150 target=3
151 ),
152 frappe._dict(
153 doctype='Employee',
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530154 title=_('Create Employee Records'),
155 description=_('Create Employee records to manage leaves, expense claims and payroll'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530156 action=_('Create Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530157 route='List/Employee',
158 target=3
159 )
160 ]
161
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530162 for m in message_settings:
163 if not m.domain or domain in m.domain:
164 m.count = frappe.db.count(m.doctype)
165 if m.count < m.target:
166 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530167
Nabin Haita2afc4e2017-02-27 15:39:29 +0530168 return messages