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