Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

151 righe
3.8 KiB

  1. # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
  2. # License: GNU General Public License v3. See license.txt
  3. import frappe
  4. from frappe import _
  5. import erpnext
  6. def get_level():
  7. activation_level = 0
  8. sales_data = []
  9. min_count = 0
  10. doctypes = {
  11. "Asset": 5,
  12. "BOM": 3,
  13. "Customer": 5,
  14. "Delivery Note": 5,
  15. "Employee": 3,
  16. "Issue": 5,
  17. "Item": 5,
  18. "Journal Entry": 3,
  19. "Lead": 3,
  20. "Material Request": 5,
  21. "Opportunity": 5,
  22. "Payment Entry": 2,
  23. "Project": 5,
  24. "Purchase Order": 2,
  25. "Purchase Invoice": 5,
  26. "Purchase Receipt": 5,
  27. "Quotation": 3,
  28. "Sales Order": 2,
  29. "Sales Invoice": 2,
  30. "Stock Entry": 3,
  31. "Supplier": 5,
  32. "Task": 5,
  33. "User": 5,
  34. "Work Order": 5,
  35. }
  36. for doctype, min_count in doctypes.items():
  37. count = frappe.db.count(doctype)
  38. if count > min_count:
  39. activation_level += 1
  40. sales_data.append({doctype: count})
  41. if frappe.db.get_single_value("System Settings", "setup_complete"):
  42. activation_level += 1
  43. communication_number = frappe.db.count("Communication", dict(communication_medium="Email"))
  44. if communication_number > 10:
  45. activation_level += 1
  46. sales_data.append({"Communication": communication_number})
  47. # recent login
  48. if frappe.db.sql(
  49. "select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1"
  50. ):
  51. activation_level += 1
  52. level = {"activation_level": activation_level, "sales_data": sales_data}
  53. return level
  54. def get_help_messages():
  55. """Returns help messages to be shown on Desktop"""
  56. if get_level() > 6:
  57. return []
  58. domain = frappe.get_cached_value("Company", erpnext.get_default_company(), "domain")
  59. messages = []
  60. message_settings = [
  61. frappe._dict(
  62. doctype="Lead",
  63. title=_("Create Leads"),
  64. description=_("Leads help you get business, add all your contacts and more as your leads"),
  65. action=_("Create Lead"),
  66. route="List/Lead",
  67. domain=("Manufacturing", "Retail", "Services", "Distribution"),
  68. target=3,
  69. ),
  70. frappe._dict(
  71. doctype="Quotation",
  72. title=_("Create customer quotes"),
  73. description=_("Quotations are proposals, bids you have sent to your customers"),
  74. action=_("Create Quotation"),
  75. route="List/Quotation",
  76. domain=("Manufacturing", "Retail", "Services", "Distribution"),
  77. target=3,
  78. ),
  79. frappe._dict(
  80. doctype="Sales Order",
  81. title=_("Manage your orders"),
  82. description=_("Create Sales Orders to help you plan your work and deliver on-time"),
  83. action=_("Create Sales Order"),
  84. route="List/Sales Order",
  85. domain=("Manufacturing", "Retail", "Services", "Distribution"),
  86. target=3,
  87. ),
  88. frappe._dict(
  89. doctype="Purchase Order",
  90. title=_("Create Purchase Orders"),
  91. description=_("Purchase orders help you plan and follow up on your purchases"),
  92. action=_("Create Purchase Order"),
  93. route="List/Purchase Order",
  94. domain=("Manufacturing", "Retail", "Services", "Distribution"),
  95. target=3,
  96. ),
  97. frappe._dict(
  98. doctype="User",
  99. title=_("Create Users"),
  100. description=_(
  101. "Add the rest of your organization as your users. You can also add invite Customers to your portal by adding them from Contacts"
  102. ),
  103. action=_("Create User"),
  104. route="List/User",
  105. domain=("Manufacturing", "Retail", "Services", "Distribution"),
  106. target=3,
  107. ),
  108. frappe._dict(
  109. doctype="Timesheet",
  110. title=_("Add Timesheets"),
  111. description=_(
  112. "Timesheets help keep track of time, cost and billing for activites done by your team"
  113. ),
  114. action=_("Create Timesheet"),
  115. route="List/Timesheet",
  116. domain=("Services",),
  117. target=5,
  118. ),
  119. frappe._dict(
  120. doctype="Employee",
  121. title=_("Create Employee Records"),
  122. description=_("Create Employee records."),
  123. action=_("Create Employee"),
  124. route="List/Employee",
  125. target=3,
  126. ),
  127. ]
  128. for m in message_settings:
  129. if not m.domain or domain in m.domain:
  130. m.count = frappe.db.count(m.doctype)
  131. if m.count < m.target:
  132. messages.append(m)
  133. return messages