blob: 0f9f2f886de38b9c49a7bc9c8c3b27e26fae085a [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 +05305import frappe, erpnext
6
7from frappe import _
Sahil Khan73e281d2019-05-09 14:32:15 +05308from six import iteritems
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05309
10def get_level():
11 activation_level = 0
Sahil Khan73e281d2019-05-09 14:32:15 +053012 sales_data = []
13 min_count = 0
Abhishek Balam123eaea2020-09-18 16:30:50 +053014 doctypes = {
15 "Asset": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053016 "BOM": 3,
17 "Customer": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053018 "Delivery Note": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053019 "Employee": 3,
20 "Instructor": 5,
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,
25 "Leave Application": 5,
26 "Material Request": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053027 "Opportunity": 5,
28 "Payment Entry": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053029 "Project": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053030 "Purchase Order": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053031 "Purchase Invoice": 5,
32 "Purchase Receipt": 5,
33 "Quotation": 3,
34 "Salary Slip": 5,
35 "Salary Structure": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053036 "Sales Order": 2,
37 "Sales Invoice": 2,
Abhishek Balam123eaea2020-09-18 16:30:50 +053038 "Stock Entry": 3,
Ankush Menat4551d7d2021-08-19 13:41:10 +053039 "Student": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053040 "Supplier": 5,
41 "Task": 5,
Ankush Menat4551d7d2021-08-19 13:41:10 +053042 "User": 5,
Abhishek Balam123eaea2020-09-18 16:30:50 +053043 "Work Order": 5
44 }
45
Sahil Khan73e281d2019-05-09 14:32:15 +053046 for doctype, min_count in iteritems(doctypes):
47 count = frappe.db.count(doctype)
48 if count > min_count:
49 activation_level += 1
50 sales_data.append({doctype: count})
51
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053052 if frappe.db.get_single_value('System Settings', 'setup_complete'):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053053 activation_level += 1
54
Sahil Khan73e281d2019-05-09 14:32:15 +053055 communication_number = frappe.db.count('Communication', dict(communication_medium='Email'))
56 if communication_number > 10:
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053057 activation_level += 1
Sahil Khan73e281d2019-05-09 14:32:15 +053058 sales_data.append({"Communication": communication_number})
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053059
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053060 # recent login
61 if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
62 activation_level += 1
63
Sahil Khan73e281d2019-05-09 14:32:15 +053064 level = {"activation_level": activation_level, "sales_data": sales_data}
65
66 return level
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053067
68def get_help_messages():
69 '''Returns help messages to be shown on Desktop'''
Rushabh Mehta7067ff02017-03-02 11:14:09 +053070 if get_level() > 6:
71 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053072
Rushabh Mehta708e47a2018-08-08 16:37:31 +053073 domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain')
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053074 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053075
Rushabh Mehtae7900b22017-03-02 11:13:18 +053076 message_settings = [
77 frappe._dict(
78 doctype='Lead',
79 title=_('Create Leads'),
80 description=_('Leads help you get business, add all your contacts and more as your leads'),
Suraj Shettyb2965002018-12-23 13:25:58 +053081 action=_('Create Lead'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053082 route='List/Lead',
83 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
84 target=3
85 ),
86 frappe._dict(
87 doctype='Quotation',
88 title=_('Create customer quotes'),
89 description=_('Quotations are proposals, bids you have sent to your customers'),
Suraj Shettyb2965002018-12-23 13:25:58 +053090 action=_('Create Quotation'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053091 route='List/Quotation',
92 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
Rushabh Mehta7067ff02017-03-02 11:14:09 +053093 target=3
Rushabh Mehtae7900b22017-03-02 11:13:18 +053094 ),
95 frappe._dict(
96 doctype='Sales Order',
97 title=_('Manage your orders'),
Suraj Shettyb2965002018-12-23 13:25:58 +053098 description=_('Create Sales Orders to help you plan your work and deliver on-time'),
99 action=_('Create Sales Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530100 route='List/Sales Order',
101 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
102 target=3
103 ),
104 frappe._dict(
105 doctype='Purchase Order',
106 title=_('Create Purchase Orders'),
107 description=_('Purchase orders help you plan and follow up on your purchases'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530108 action=_('Create Purchase Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530109 route='List/Purchase Order',
110 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
111 target=3
112 ),
113 frappe._dict(
114 doctype='User',
115 title=_('Create Users'),
116 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 +0530117 action=_('Create User'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530118 route='List/User',
119 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
120 target=3
121 ),
122 frappe._dict(
123 doctype='Timesheet',
124 title=_('Add Timesheets'),
125 description=_('Timesheets help keep track of time, cost and billing for activites done by your team'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530126 action=_('Create Timesheet'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530127 route='List/Timesheet',
128 domain=('Services',),
129 target=5
130 ),
131 frappe._dict(
132 doctype='Student',
133 title=_('Add Students'),
134 description=_('Students are at the heart of the system, add all your students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530135 action=_('Create Student'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530136 route='List/Student',
137 domain=('Education',),
138 target=5
139 ),
140 frappe._dict(
141 doctype='Student Batch',
142 title=_('Group your students in batches'),
143 description=_('Student Batches help you track attendance, assessments and fees for students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530144 action=_('Create Student Batch'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530145 route='List/Student Batch',
146 domain=('Education',),
147 target=3
148 ),
149 frappe._dict(
150 doctype='Employee',
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530151 title=_('Create Employee Records'),
152 description=_('Create Employee records to manage leaves, expense claims and payroll'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530153 action=_('Create Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530154 route='List/Employee',
155 target=3
156 )
157 ]
158
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530159 for m in message_settings:
160 if not m.domain or domain in m.domain:
161 m.count = frappe.db.count(m.doctype)
162 if m.count < m.target:
163 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530164
Nabin Haita2afc4e2017-02-27 15:39:29 +0530165 return messages