blob: 63c36b35d1f3b3e2104153a6d5daddd4b3071b6d [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 _
Sahil Khan73e281d2019-05-09 14:32:15 +05308from six import iteritems
Rushabh Mehta6dd461f2017-02-16 14:51:48 +05309
10def get_level():
11 activation_level = 0
Sahil Khan73e281d2019-05-09 14:32:15 +053012 sales_data = []
13 min_count = 0
14 doctypes = {"Item": 5, "Customer": 5, "Sales Order": 2, "Sales Invoice": 2, "Purchase Order": 2, "Employee": 3, "Lead": 3, "Quotation": 3,
15 "Payment Entry": 2, "User": 5, "Student": 5, "Instructor": 5, "BOM": 3, "Journal Entry": 3, "Stock Entry": 3}
16 for doctype, min_count in iteritems(doctypes):
17 count = frappe.db.count(doctype)
18 if count > min_count:
19 activation_level += 1
20 sales_data.append({doctype: count})
21
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053022 if frappe.db.get_single_value('System Settings', 'setup_complete'):
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053023 activation_level += 1
24
Sahil Khan73e281d2019-05-09 14:32:15 +053025 communication_number = frappe.db.count('Communication', dict(communication_medium='Email'))
26 if communication_number > 10:
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053027 activation_level += 1
Sahil Khan73e281d2019-05-09 14:32:15 +053028 sales_data.append({"Communication": communication_number})
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053029
Rushabh Mehta6dd461f2017-02-16 14:51:48 +053030 # recent login
31 if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
32 activation_level += 1
33
Sahil Khan73e281d2019-05-09 14:32:15 +053034 level = {"activation_level": activation_level, "sales_data": sales_data}
35
36 return level
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053037
38def get_help_messages():
39 '''Returns help messages to be shown on Desktop'''
Rushabh Mehta7067ff02017-03-02 11:14:09 +053040 if get_level() > 6:
41 return []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053042
Rushabh Mehta708e47a2018-08-08 16:37:31 +053043 domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain')
Prateeksha Singh95d8fd32017-09-04 11:14:04 +053044 messages = []
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +053045
Rushabh Mehtae7900b22017-03-02 11:13:18 +053046 message_settings = [
47 frappe._dict(
48 doctype='Lead',
49 title=_('Create Leads'),
50 description=_('Leads help you get business, add all your contacts and more as your leads'),
Suraj Shettyb2965002018-12-23 13:25:58 +053051 action=_('Create Lead'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053052 route='List/Lead',
53 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
54 target=3
55 ),
56 frappe._dict(
57 doctype='Quotation',
58 title=_('Create customer quotes'),
59 description=_('Quotations are proposals, bids you have sent to your customers'),
Suraj Shettyb2965002018-12-23 13:25:58 +053060 action=_('Create Quotation'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053061 route='List/Quotation',
62 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
Rushabh Mehta7067ff02017-03-02 11:14:09 +053063 target=3
Rushabh Mehtae7900b22017-03-02 11:13:18 +053064 ),
65 frappe._dict(
66 doctype='Sales Order',
67 title=_('Manage your orders'),
Suraj Shettyb2965002018-12-23 13:25:58 +053068 description=_('Create Sales Orders to help you plan your work and deliver on-time'),
69 action=_('Create Sales Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053070 route='List/Sales Order',
71 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
72 target=3
73 ),
74 frappe._dict(
75 doctype='Purchase Order',
76 title=_('Create Purchase Orders'),
77 description=_('Purchase orders help you plan and follow up on your purchases'),
Suraj Shettyb2965002018-12-23 13:25:58 +053078 action=_('Create Purchase Order'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053079 route='List/Purchase Order',
80 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
81 target=3
82 ),
83 frappe._dict(
84 doctype='User',
85 title=_('Create Users'),
86 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 +053087 action=_('Create User'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053088 route='List/User',
89 domain=('Manufacturing', 'Retail', 'Services', 'Distribution'),
90 target=3
91 ),
92 frappe._dict(
93 doctype='Timesheet',
94 title=_('Add Timesheets'),
95 description=_('Timesheets help keep track of time, cost and billing for activites done by your team'),
Suraj Shettyb2965002018-12-23 13:25:58 +053096 action=_('Create Timesheet'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +053097 route='List/Timesheet',
98 domain=('Services',),
99 target=5
100 ),
101 frappe._dict(
102 doctype='Student',
103 title=_('Add Students'),
104 description=_('Students are at the heart of the system, add all your students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530105 action=_('Create Student'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530106 route='List/Student',
107 domain=('Education',),
108 target=5
109 ),
110 frappe._dict(
111 doctype='Student Batch',
112 title=_('Group your students in batches'),
113 description=_('Student Batches help you track attendance, assessments and fees for students'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530114 action=_('Create Student Batch'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530115 route='List/Student Batch',
116 domain=('Education',),
117 target=3
118 ),
119 frappe._dict(
120 doctype='Employee',
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530121 title=_('Create Employee Records'),
122 description=_('Create Employee records to manage leaves, expense claims and payroll'),
Suraj Shettyb2965002018-12-23 13:25:58 +0530123 action=_('Create Employee'),
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530124 route='List/Employee',
125 target=3
126 )
127 ]
128
Rushabh Mehtae7900b22017-03-02 11:13:18 +0530129 for m in message_settings:
130 if not m.domain or domain in m.domain:
131 m.count = frappe.db.count(m.doctype)
132 if m.count < m.target:
133 messages.append(m)
Rushabh Mehta05ce7ec2017-02-22 16:15:43 +0530134
Nabin Haita2afc4e2017-02-27 15:39:29 +0530135 return messages