blob: baede3153774e102f813890ca94e3fcc59b0cb9a [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 Mehtaf8b19e02017-02-28 18:54:07 +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
61 if domain in ('Manufacturing', 'Retail', 'Services', 'Distribution'):
62 count = frappe.db.count('Lead')
63 if count < 3:
64 messages.append(dict(
65 title=_('Create Leads'),
Nabin Haita2afc4e2017-02-27 15:39:29 +053066 description=_('Leads help you get business, add all your contacts and more as your leads'),
67 action=_('Make Lead'),
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053068 route='List/Lead',
69 count=count
70 ))
71
72 count = frappe.db.count('Quotation')
73 if count < 3:
74 messages.append(dict(
75 title=_('Create customer quotes'),
76 description=_('Quotations are proposals, bids you have sent to your customers'),
77 action=_('Make Quotation'),
78 route='List/Quotation'
79 ))
80
81 count = frappe.db.count('Sales Order')
82 if count < 3:
83 messages.append(dict(
84 title=_('Manage your orders'),
85 description=_('Make Sales Orders to help you plan your work and deliver on-time'),
86 action=_('Make Sales Order'),
87 route='List/Sales Order'
88 ))
89
90 count = frappe.db.count('Purchase Order')
91 if count < 3:
92 messages.append(dict(
93 title=_('Create Purchase Orders'),
94 description=_('Purchase orders help you plan and follow up on your purchases'),
95 action=_('Make Purchase Order'),
96 route='List/Purchase Order'
97 ))
98
99 count = frappe.db.count('User')
100 if count < 3:
101 messages.append(dict(
102 title=_('Create Users'),
103 description=_('Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts'),
104 action=_('Make User'),
105 route='List/User'
106 ))
107
108 elif domain == 'Education':
109 count = frappe.db.count('Student')
110 if count < 5:
111 messages.append(dict(
112 title=_('Add Students'),
113 description=_('Students are at the heart of the system, add all your students'),
114 action=_('Make Student'),
115 route='List/Student'
116 ))
117
118 count = frappe.db.count('Student Batch')
119 if count < 3:
120 messages.append(dict(
121 title=_('Group your students in batches'),
122 description=_('Student Batches help you track attendance, assessments and fees for students'),
123 action=_('Make Student Batch'),
124 route='List/Student Batch'
125 ))
126
127 # anyways
128 count = frappe.db.count('Employee')
129 if count < 3:
130 messages.append(dict(
131 title=_('Create Employee Records'),
132 description=_('Create Employee records to manage leaves, expense claims and payroll'),
133 action=_('Make Employee'),
134 route='List/Employee'
135 ))
136
Nabin Haita2afc4e2017-02-27 15:39:29 +0530137 return messages