blob: 5f261fac132477aa12d12f2f29becda5e694c438 [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 _
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05308
9def get_level():
10 activation_level = 0
11 if frappe.db.get_single_value('System Settings', 'setup_complete'):
12 activation_level = 1
13
14 if frappe.db.count('Item') > 5:
15 activation_level += 1
16
17 if frappe.db.count('Customer') > 5:
18 activation_level += 1
19
20 if frappe.db.count('Sales Order') > 2:
21 activation_level += 1
22
23 if frappe.db.count('Purchase Order') > 2:
24 activation_level += 1
25
26 if frappe.db.count('Employee') > 3:
27 activation_level += 1
28
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053029 if frappe.db.count('Lead') > 3:
30 activation_level += 1
31
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053032 if frappe.db.count('Payment Entry') > 2:
33 activation_level += 1
34
35 if frappe.db.count('Communication', dict(communication_medium='Email')) > 10:
36 activation_level += 1
37
38 if frappe.db.count('User') > 5:
39 activation_level += 1
40
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053041 if frappe.db.count('Student') > 5:
42 activation_level += 1
43
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053044 if frappe.db.count('Instructor') > 5:
45 activation_level += 1
46
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053047 # recent login
48 if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
49 activation_level += 1
50
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053051 return activation_level
52
53def get_help_messages():
54 '''Returns help messages to be shown on Desktop'''
Rushabh Mehta7067ff02017-03-02 11:14:09 +053055 if get_level() > 6:
56 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053057
Rushabh Mehta708e47a2018-08-08 16:37:31 +053058 domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain')
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053059 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053060
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'),
Suraj Shettyb2965002018-12-23 13:25:58 +053066 action=_('Create Lead'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053067 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +053075 action=_('Create Quotation'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053076 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +053083 description=_('Create Sales Orders to help you plan your work and deliver on-time'),
84 action=_('Create Sales Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053085 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +053093 action=_('Create Purchase Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053094 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530102 action=_('Create User'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530103 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530111 action=_('Create Timesheet'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530112 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530120 action=_('Create Student'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530121 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530129 action=_('Create Student Batch'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530130 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'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530138 action=_('Create Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530139 route='List/Employee',
140 target=3
141 )
142 ]
143
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530144 for m in message_settings:
145 if not m.domain or domain in m.domain:
146 m.count = frappe.db.count(m.doctype)
147 if m.count < m.target:
148 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530149
Nabin Haita2afc4e2017-02-27 15:39:29 +0530150 return messages