blob: b694ea609b1099d906b3510632136ceeb11f740a [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 +05304import frappe, erpnext
5
6from frappe import _
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05307
8def get_level():
9 activation_level = 0
10 if frappe.db.get_single_value('System Settings', 'setup_complete'):
11 activation_level = 1
12
13 if frappe.db.count('Item') > 5:
14 activation_level += 1
15
16 if frappe.db.count('Customer') > 5:
17 activation_level += 1
18
19 if frappe.db.count('Sales Order') > 2:
20 activation_level += 1
21
22 if frappe.db.count('Purchase Order') > 2:
23 activation_level += 1
24
25 if frappe.db.count('Employee') > 3:
26 activation_level += 1
27
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053028 if frappe.db.count('Lead') > 3:
29 activation_level += 1
30
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053031 if frappe.db.count('Payment Entry') > 2:
32 activation_level += 1
33
34 if frappe.db.count('Communication', dict(communication_medium='Email')) > 10:
35 activation_level += 1
36
37 if frappe.db.count('User') > 5:
38 activation_level += 1
39
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053040 if frappe.db.count('Student') > 5:
41 activation_level += 1
42
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053043 if frappe.db.count('Instructor') > 5:
44 activation_level += 1
45
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053046 # recent login
47 if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
48 activation_level += 1
49
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053050 return activation_level
51
52def get_help_messages():
53 '''Returns help messages to be shown on Desktop'''
Rushabh Mehta7067ff02017-03-02 11:14:09 +053054 if get_level() > 6:
55 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053056
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053057 domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain')
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053058 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053059
Rushabh Mehtae7900b22017-03-02 11:13:18 +053060 message_settings = [
61 frappe._dict(
62 doctype='Lead',
63 title=_('Create Leads'),
64 description=_('Leads help you get business, add all your contacts and more as your leads'),
65 action=_('Make Lead'),
66 route='List/Lead',
67 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
68 target=3
69 ),
70 frappe._dict(
71 doctype='Quotation',
72 title=_('Create customer quotes'),
73 description=_('Quotations are proposals, bids you have sent to your customers'),
74 action=_('Make Quotation'),
75 route='List/Quotation',
76 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
Rushabh Mehta7067ff02017-03-02 11:14:09 +053077 target=3
Rushabh Mehtae7900b22017-03-02 11:13:18 +053078 ),
79 frappe._dict(
80 doctype='Sales Order',
81 title=_('Manage your orders'),
82 description=_('Make Sales Orders to help you plan your work and deliver on-time'),
83 action=_('Make Sales Order'),
84 route='List/Sales Order',
85 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
86 target=3
87 ),
88 frappe._dict(
89 doctype='Purchase Order',
90 title=_('Create Purchase Orders'),
91 description=_('Purchase orders help you plan and follow up on your purchases'),
92 action=_('Make Purchase Order'),
93 route='List/Purchase Order',
94 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
95 target=3
96 ),
97 frappe._dict(
98 doctype='User',
99 title=_('Create Users'),
100 description=_('Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts'),
101 action=_('Make User'),
102 route='List/User',
103 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
104 target=3
105 ),
106 frappe._dict(
107 doctype='Timesheet',
108 title=_('Add Timesheets'),
109 description=_('Timesheets help keep track of time, cost and billing for activites done by your team'),
110 action=_('Make Timesheet'),
111 route='List/Timesheet',
112 domain=('Services',),
113 target=5
114 ),
115 frappe._dict(
116 doctype='Student',
117 title=_('Add Students'),
118 description=_('Students are at the heart of the system, add all your students'),
119 action=_('Make Student'),
120 route='List/Student',
121 domain=('Education',),
122 target=5
123 ),
124 frappe._dict(
125 doctype='Student Batch',
126 title=_('Group your students in batches'),
127 description=_('Student Batches help you track attendance, assessments and fees for students'),
128 action=_('Make Student Batch'),
129 route='List/Student Batch',
130 domain=('Education',),
131 target=3
132 ),
133 frappe._dict(
134 doctype='Employee',
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530135 title=_('Create Employee Records'),
136 description=_('Create Employee records to manage leaves, expense claims and payroll'),
137 action=_('Make Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530138 route='List/Employee',
139 target=3
140 )
141 ]
142
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530143 for m in message_settings:
144 if not m.domain or domain in m.domain:
145 m.count = frappe.db.count(m.doctype)
146 if m.count < m.target:
147 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530148
Nabin Haita2afc4e2017-02-27 15:39:29 +0530149 return messages