2017-09-04 05:44:04 +00:00
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2017-02-22 10:45:43 +00:00
|
|
|
|
|
|
|
import frappe
|
|
|
|
from frappe import _
|
2017-02-16 09:21:48 +00:00
|
|
|
|
2017-02-22 10:45:43 +00:00
|
|
|
import erpnext
|
2021-09-02 11:14:59 +00:00
|
|
|
|
|
|
|
|
2017-02-16 09:21:48 +00:00
|
|
|
def get_level():
|
|
|
|
activation_level = 0
|
2019-05-09 09:02:15 +00:00
|
|
|
sales_data = []
|
|
|
|
min_count = 0
|
2020-09-18 11:00:50 +00:00
|
|
|
doctypes = {
|
|
|
|
"Asset": 5,
|
|
|
|
"BOM": 3,
|
|
|
|
"Customer": 5,
|
|
|
|
"Delivery Note": 5,
|
|
|
|
"Employee": 3,
|
|
|
|
"Issue": 5,
|
|
|
|
"Item": 5,
|
|
|
|
"Journal Entry": 3,
|
|
|
|
"Lead": 3,
|
|
|
|
"Material Request": 5,
|
|
|
|
"Opportunity": 5,
|
|
|
|
"Payment Entry": 2,
|
|
|
|
"Project": 5,
|
|
|
|
"Purchase Order": 2,
|
|
|
|
"Purchase Invoice": 5,
|
|
|
|
"Purchase Receipt": 5,
|
|
|
|
"Quotation": 3,
|
|
|
|
"Sales Order": 2,
|
|
|
|
"Sales Invoice": 2,
|
|
|
|
"Stock Entry": 3,
|
|
|
|
"Supplier": 5,
|
|
|
|
"Task": 5,
|
|
|
|
"User": 5,
|
|
|
|
"Work Order": 5,
|
|
|
|
}
|
|
|
|
|
2019-05-09 09:02:15 +00:00
|
|
|
for doctype, min_count in doctypes.items():
|
|
|
|
count = frappe.db.count(doctype)
|
|
|
|
if count > min_count:
|
|
|
|
activation_level += 1
|
|
|
|
sales_data.append({doctype: count})
|
2017-02-16 09:21:48 +00:00
|
|
|
|
2019-05-09 09:02:15 +00:00
|
|
|
if frappe.db.get_single_value("System Settings", "setup_complete"):
|
2017-02-22 10:45:43 +00:00
|
|
|
activation_level += 1
|
|
|
|
|
2019-05-09 09:02:15 +00:00
|
|
|
communication_number = frappe.db.count("Communication", dict(communication_medium="Email"))
|
|
|
|
if communication_number > 10:
|
2017-02-22 10:45:43 +00:00
|
|
|
activation_level += 1
|
2019-05-09 09:02:15 +00:00
|
|
|
sales_data.append({"Communication": communication_number})
|
2017-02-22 10:45:43 +00:00
|
|
|
|
2017-02-16 09:21:48 +00:00
|
|
|
# recent login
|
|
|
|
if frappe.db.sql(
|
|
|
|
"select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1"
|
|
|
|
):
|
|
|
|
activation_level += 1
|
|
|
|
|
2019-05-09 09:02:15 +00:00
|
|
|
level = {"activation_level": activation_level, "sales_data": sales_data}
|
|
|
|
|
|
|
|
return level
|
2017-02-22 10:45:43 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2017-02-22 10:45:43 +00:00
|
|
|
def get_help_messages():
|
|
|
|
"""Returns help messages to be shown on Desktop"""
|
2017-03-02 05:44:09 +00:00
|
|
|
if get_level() > 6:
|
|
|
|
return []
|
2017-02-22 10:45:43 +00:00
|
|
|
|
2018-08-08 11:07:31 +00:00
|
|
|
domain = frappe.get_cached_value("Company", erpnext.get_default_company(), "domain")
|
2017-09-04 05:44:04 +00:00
|
|
|
messages = []
|
2017-02-22 10:45:43 +00:00
|
|
|
|
2017-03-02 05:43:18 +00:00
|
|
|
message_settings = [
|
|
|
|
frappe._dict(
|
|
|
|
doctype="Lead",
|
|
|
|
title=_("Create Leads"),
|
|
|
|
description=_("Leads help you get business, add all your contacts and more as your leads"),
|
2018-12-23 07:55:58 +00:00
|
|
|
action=_("Create Lead"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/Lead",
|
|
|
|
domain=("Manufacturing", "Retail", "Services", "Distribution"),
|
|
|
|
target=3,
|
|
|
|
),
|
|
|
|
frappe._dict(
|
|
|
|
doctype="Quotation",
|
|
|
|
title=_("Create customer quotes"),
|
|
|
|
description=_("Quotations are proposals, bids you have sent to your customers"),
|
2018-12-23 07:55:58 +00:00
|
|
|
action=_("Create Quotation"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/Quotation",
|
|
|
|
domain=("Manufacturing", "Retail", "Services", "Distribution"),
|
2017-03-02 05:44:09 +00:00
|
|
|
target=3,
|
2017-03-02 05:43:18 +00:00
|
|
|
),
|
|
|
|
frappe._dict(
|
|
|
|
doctype="Sales Order",
|
|
|
|
title=_("Manage your orders"),
|
2018-12-23 07:55:58 +00:00
|
|
|
description=_("Create Sales Orders to help you plan your work and deliver on-time"),
|
|
|
|
action=_("Create Sales Order"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/Sales Order",
|
|
|
|
domain=("Manufacturing", "Retail", "Services", "Distribution"),
|
|
|
|
target=3,
|
|
|
|
),
|
|
|
|
frappe._dict(
|
|
|
|
doctype="Purchase Order",
|
|
|
|
title=_("Create Purchase Orders"),
|
|
|
|
description=_("Purchase orders help you plan and follow up on your purchases"),
|
2018-12-23 07:55:58 +00:00
|
|
|
action=_("Create Purchase Order"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/Purchase Order",
|
|
|
|
domain=("Manufacturing", "Retail", "Services", "Distribution"),
|
|
|
|
target=3,
|
|
|
|
),
|
|
|
|
frappe._dict(
|
|
|
|
doctype="User",
|
|
|
|
title=_("Create Users"),
|
|
|
|
description=_(
|
|
|
|
"Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts"
|
|
|
|
),
|
2018-12-23 07:55:58 +00:00
|
|
|
action=_("Create User"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/User",
|
|
|
|
domain=("Manufacturing", "Retail", "Services", "Distribution"),
|
|
|
|
target=3,
|
|
|
|
),
|
|
|
|
frappe._dict(
|
|
|
|
doctype="Timesheet",
|
|
|
|
title=_("Add Timesheets"),
|
|
|
|
description=_(
|
|
|
|
"Timesheets help keep track of time, cost and billing for activites done by your team"
|
|
|
|
),
|
2018-12-23 07:55:58 +00:00
|
|
|
action=_("Create Timesheet"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/Timesheet",
|
|
|
|
domain=("Services",),
|
|
|
|
target=5,
|
|
|
|
),
|
|
|
|
frappe._dict(
|
|
|
|
doctype="Employee",
|
2017-02-22 10:45:43 +00:00
|
|
|
title=_("Create Employee Records"),
|
2022-07-01 05:04:32 +00:00
|
|
|
description=_("Create Employee records."),
|
2018-12-23 07:55:58 +00:00
|
|
|
action=_("Create Employee"),
|
2017-03-02 05:43:18 +00:00
|
|
|
route="List/Employee",
|
|
|
|
target=3,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
for m in message_settings:
|
|
|
|
if not m.domain or domain in m.domain:
|
|
|
|
m.count = frappe.db.count(m.doctype)
|
|
|
|
if m.count < m.target:
|
|
|
|
messages.append(m)
|
2017-02-22 10:45:43 +00:00
|
|
|
|
2017-02-27 10:09:29 +00:00
|
|
|
return messages
|