blob: c4841bb619fb3ccfd61f06328b98b984aabc6958 [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
40 if frappe.db.count('Student Batch') > 5:
41 activation_level += 1
42
43 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
57 messages = []
58
59 domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain')
60
Rushabh Mehtae7900b22017-03-02 11:13:18 +053061 message_settings = [
62 frappe._dict(
63 doctype='Lead',
64 title=_('Create Leads'),
65 description=_('Leads help you get business, add all your contacts and more as your leads'),
66 action=_('Make Lead'),
67 route='List/Lead',
68 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
69 target=3
70 ),
71 frappe._dict(
72 doctype='Quotation',
73 title=_('Create customer quotes'),
74 description=_('Quotations are proposals, bids you have sent to your customers'),
75 action=_('Make Quotation'),
76 route='List/Quotation',
77 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
Rushabh Mehta7067ff02017-03-02 11:14:09 +053078 target=3
Rushabh Mehtae7900b22017-03-02 11:13:18 +053079 ),
80 frappe._dict(
81 doctype='Sales Order',
82 title=_('Manage your orders'),
83 description=_('Make Sales Orders to help you plan your work and deliver on-time'),
84 action=_('Make Sales Order'),
85 route='List/Sales Order',
86 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
87 target=3
88 ),
89 frappe._dict(
90 doctype='Purchase Order',
91 title=_('Create Purchase Orders'),
92 description=_('Purchase orders help you plan and follow up on your purchases'),
93 action=_('Make Purchase Order'),
94 route='List/Purchase Order',
95 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
96 target=3
97 ),
98 frappe._dict(
99 doctype='User',
100 title=_('Create Users'),
101 description=_('Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts'),
102 action=_('Make User'),
103 route='List/User',
104 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
105 target=3
106 ),
107 frappe._dict(
108 doctype='Timesheet',
109 title=_('Add Timesheets'),
110 description=_('Timesheets help keep track of time, cost and billing for activites done by your team'),
111 action=_('Make Timesheet'),
112 route='List/Timesheet',
113 domain=('Services',),
114 target=5
115 ),
116 frappe._dict(
117 doctype='Student',
118 title=_('Add Students'),
119 description=_('Students are at the heart of the system, add all your students'),
120 action=_('Make Student'),
121 route='List/Student',
122 domain=('Education',),
123 target=5
124 ),
125 frappe._dict(
126 doctype='Student Batch',
127 title=_('Group your students in batches'),
128 description=_('Student Batches help you track attendance, assessments and fees for students'),
129 action=_('Make Student Batch'),
130 route='List/Student Batch',
131 domain=('Education',),
132 target=3
133 ),
134 frappe._dict(
135 doctype='Employee',
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530136 title=_('Create Employee Records'),
137 description=_('Create Employee records to manage leaves, expense claims and payroll'),
138 action=_('Make Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530139 route='List/Employee',
140 target=3
141 )
142 ]
143
144
145 for m in message_settings:
146 if not m.domain or domain in m.domain:
147 m.count = frappe.db.count(m.doctype)
148 if m.count < m.target:
149 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530150
Nabin Haita2afc4e2017-02-27 15:39:29 +0530151 return messages