mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
fix: user progress code cleanup
This commit is contained in:
@@ -7,19 +7,12 @@ import frappe, erpnext
|
||||
import json
|
||||
from frappe import _
|
||||
from frappe.utils import flt
|
||||
from erpnext.setup.doctype.setup_progress.setup_progress import update_domain_actions, get_domain_actions_state
|
||||
|
||||
@frappe.whitelist()
|
||||
def set_sales_target(args_data):
|
||||
args = json.loads(args_data)
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
frappe.db.set_value("Company", defaults.get("company"), "monthly_sales_target", args.get('monthly_sales_target'))
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_customers(args_data):
|
||||
args = json.loads(args_data)
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
customer = args.get("customer_name_" + str(i))
|
||||
if customer:
|
||||
try:
|
||||
@@ -57,7 +50,7 @@ def create_letterhead(args_data):
|
||||
def create_suppliers(args_data):
|
||||
args = json.loads(args_data)
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
supplier = args.get("supplier_name_" + str(i))
|
||||
if supplier:
|
||||
try:
|
||||
@@ -90,7 +83,7 @@ def create_contact(contact, party_type, party):
|
||||
def create_items(args_data):
|
||||
args = json.loads(args_data)
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
for i in range(1,4):
|
||||
for i in range(1, args.get('max_count')):
|
||||
item = args.get("item_" + str(i))
|
||||
if item:
|
||||
default_warehouse = ""
|
||||
@@ -141,7 +134,7 @@ def make_item_price(item, price_list_name, item_price):
|
||||
@frappe.whitelist()
|
||||
def create_program(args_data):
|
||||
args = json.loads(args_data)
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
if args.get("program_" + str(i)):
|
||||
program = frappe.new_doc("Program")
|
||||
program.program_code = args.get("program_" + str(i))
|
||||
@@ -154,7 +147,7 @@ def create_program(args_data):
|
||||
@frappe.whitelist()
|
||||
def create_course(args_data):
|
||||
args = json.loads(args_data)
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
if args.get("course_" + str(i)):
|
||||
course = frappe.new_doc("Course")
|
||||
course.course_code = args.get("course_" + str(i))
|
||||
@@ -167,7 +160,7 @@ def create_course(args_data):
|
||||
@frappe.whitelist()
|
||||
def create_instructor(args_data):
|
||||
args = json.loads(args_data)
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
if args.get("instructor_" + str(i)):
|
||||
instructor = frappe.new_doc("Instructor")
|
||||
instructor.instructor_name = args.get("instructor_" + str(i))
|
||||
@@ -179,7 +172,7 @@ def create_instructor(args_data):
|
||||
@frappe.whitelist()
|
||||
def create_room(args_data):
|
||||
args = json.loads(args_data)
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
if args.get("room_" + str(i)):
|
||||
room = frappe.new_doc("Room")
|
||||
room.room_name = args.get("room_" + str(i))
|
||||
@@ -195,7 +188,7 @@ def create_users(args_data):
|
||||
return
|
||||
args = json.loads(args_data)
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
for i in range(1,4):
|
||||
for i in range(1,args.get('max_count')):
|
||||
email = args.get("user_email_" + str(i))
|
||||
fullname = args.get("user_fullname_" + str(i))
|
||||
if email:
|
||||
@@ -231,4 +224,4 @@ def create_users(args_data):
|
||||
emp.flags.ignore_mandatory = True
|
||||
emp.insert(ignore_permissions = True)
|
||||
|
||||
# Ennumerate the setup hooks you're going to need, apart from the slides
|
||||
# Enumerate the setup hooks you're going to need, apart from the slides
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe, erpnext
|
||||
from frappe import _
|
||||
from erpnext.setup.doctype.setup_progress.setup_progress import get_action_completed_state
|
||||
|
||||
def get_slide_settings():
|
||||
defaults = frappe.defaults.get_defaults()
|
||||
domain = frappe.get_cached_value('Company', erpnext.get_default_company(), 'domain')
|
||||
company = defaults.get("company") or ''
|
||||
currency = defaults.get("currency") or ''
|
||||
|
||||
doc = frappe.get_doc("Setup Progress")
|
||||
item = [d for d in doc.get("actions") if d.action_name == "Set Sales Target"]
|
||||
|
||||
if len(item):
|
||||
item = item[0]
|
||||
if not item.action_document:
|
||||
item.action_document = company
|
||||
doc.save()
|
||||
|
||||
# Initial state of slides
|
||||
return [
|
||||
frappe._dict(
|
||||
action_name='Add Company',
|
||||
title=_("Setup Company") if domain != 'Education' else _("Setup Institution"),
|
||||
help=_('Setup your ' + ('company' if domain != 'Education' else 'institution') + ' and brand.'),
|
||||
# image_src="/assets/erpnext/images/illustrations/shop.jpg",
|
||||
fields=[],
|
||||
done_state_title=_("You added " + company),
|
||||
done_state_title_route=["Form", "Company", company],
|
||||
help_links=[
|
||||
{
|
||||
"label": _("Chart of Accounts"),
|
||||
"url": ["https://erpnext.com/docs/user/manual/en/accounts/chart-of-accounts"]
|
||||
},
|
||||
{
|
||||
"label": _("Opening Balances"),
|
||||
"video_id": "U5wPIvEn-0c"
|
||||
}
|
||||
]
|
||||
),
|
||||
frappe._dict(
|
||||
action_name='Set Sales Target',
|
||||
domains=('Manufacturing', 'Services', 'Retail', 'Distribution'),
|
||||
title=_("Set a Target"),
|
||||
help=_("Set a sales goal you'd like to achieve for your company."),
|
||||
fields=[
|
||||
{"fieldtype":"Currency", "fieldname":"monthly_sales_target",
|
||||
"label":_("Monthly Sales Target (" + currency + ")"), "reqd":1},
|
||||
],
|
||||
submit_method="erpnext.utilities.user_progress_utils.set_sales_target",
|
||||
done_state_title=_("Go to " + company),
|
||||
done_state_title_route=["Form", "Company", company],
|
||||
help_links=[
|
||||
{
|
||||
"label": _('Learn More'),
|
||||
"url": ["https://erpnext.com/docs/user/manual/en/setting-up/setting-company-sales-goal"]
|
||||
}
|
||||
]
|
||||
),
|
||||
frappe._dict(
|
||||
action_name='Add Customers',
|
||||
domains=('Manufacturing', 'Services', 'Retail', 'Distribution'),
|
||||
title=_("Add Customers"),
|
||||
help=_("List a few of your customers. They could be organizations or individuals."),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break"},
|
||||
{"fieldtype":"Data", "fieldname":"customer", "label":_("Customer"),
|
||||
"placeholder":_("Customer Name")},
|
||||
{"fieldtype":"Column Break"},
|
||||
{"fieldtype":"Data", "fieldname":"customer_contact",
|
||||
"label":_("Contact Name"), "placeholder":_("Contact Name")}
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_customers",
|
||||
done_state_title=_("Go to Customers"),
|
||||
done_state_title_route=["List", "Customer"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _('Learn More'),
|
||||
"url": ["https://erpnext.com/docs/user/manual/en/CRM/customer.html"]
|
||||
}
|
||||
]
|
||||
),
|
||||
|
||||
frappe._dict(
|
||||
action_name='Add Letterhead',
|
||||
domains=('Manufacturing', 'Services', 'Retail', 'Distribution', 'Education'),
|
||||
title=_("Add Letterhead"),
|
||||
help=_("Upload your letter head (Keep it web friendly as 900px by 100px)"),
|
||||
fields=[
|
||||
{"fieldtype":"Attach Image", "fieldname":"letterhead",
|
||||
"is_private": 0,
|
||||
"align": "center"
|
||||
},
|
||||
],
|
||||
mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_letterhead",
|
||||
done_state_title=_("Go to Letterheads"),
|
||||
done_state_title_route=["List", "Letter Head"]
|
||||
),
|
||||
|
||||
frappe._dict(
|
||||
action_name='Add Suppliers',
|
||||
domains=('Manufacturing', 'Services', 'Retail', 'Distribution'),
|
||||
icon="fa fa-group",
|
||||
title=_("Your Suppliers"),
|
||||
help=_("List a few of your suppliers. They could be organizations or individuals."),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break"},
|
||||
{"fieldtype":"Data", "fieldname":"supplier", "label":_("Supplier"),
|
||||
"placeholder":_("Supplier Name")},
|
||||
{"fieldtype":"Column Break"},
|
||||
{"fieldtype":"Data", "fieldname":"supplier_contact",
|
||||
"label":_("Contact Name"), "placeholder":_("Contact Name")},
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_suppliers",
|
||||
done_state_title=_("Go to Suppliers"),
|
||||
done_state_title_route=["List", "Supplier"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _('Learn More'),
|
||||
"url": ["https://erpnext.com/docs/user/manual/en/buying/supplier"]
|
||||
},
|
||||
{
|
||||
"label": _('Customers and Suppliers'),
|
||||
"video_id": "zsrrVDk6VBs"
|
||||
},
|
||||
]
|
||||
),
|
||||
frappe._dict(
|
||||
action_name='Add Products',
|
||||
domains=['Manufacturing', 'Services', 'Retail', 'Distribution'],
|
||||
icon="fa fa-barcode",
|
||||
title=_("Your Products or Services"),
|
||||
help=_("List your products or services that you buy or sell."),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break", "show_section_border": 1},
|
||||
{"fieldtype":"Data", "fieldname":"item", "label":_("Item"),
|
||||
"placeholder":_("A Product")},
|
||||
{"fieldtype":"Column Break"},
|
||||
{"fieldtype":"Select", "fieldname":"item_uom", "label":_("UOM"),
|
||||
"options":[_("Unit"), _("Nos"), _("Box"), _("Pair"), _("Kg"), _("Set"),
|
||||
_("Hour"), _("Minute"), _("Litre"), _("Meter"), _("Gram")],
|
||||
"default": _("Unit"), "static": 1},
|
||||
{"fieldtype":"Column Break"},
|
||||
{"fieldtype":"Currency", "fieldname":"item_price", "label":_("Rate"), "static": 1}
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_items",
|
||||
done_state_title=_("Go to Items"),
|
||||
done_state_title_route=["List", "Item"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _("Explore Sales Cycle"),
|
||||
"video_id": "1eP90MWoDQM"
|
||||
},
|
||||
]
|
||||
),
|
||||
|
||||
# Education slides begin
|
||||
frappe._dict(
|
||||
action_name='Add Programs',
|
||||
domains=("Education"),
|
||||
title=_("Program"),
|
||||
help=_("Example: Masters in Computer Science"),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break", "show_section_border": 1},
|
||||
{"fieldtype":"Data", "fieldname":"program", "label":_("Program"), "placeholder": _("Program Name")},
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_program",
|
||||
done_state_title=_("Go to Programs"),
|
||||
done_state_title_route=["List", "Program"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _("Student Application"),
|
||||
"video_id": "l8PUACusN3E"
|
||||
},
|
||||
]
|
||||
|
||||
),
|
||||
frappe._dict(
|
||||
action_name='Add Courses',
|
||||
domains=["Education"],
|
||||
title=_("Course"),
|
||||
help=_("Example: Basic Mathematics"),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break", "show_section_border": 1},
|
||||
{"fieldtype":"Data", "fieldname":"course", "label":_("Course"), "placeholder": _("Course Name")},
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_course",
|
||||
done_state_title=_("Go to Courses"),
|
||||
done_state_title_route=["List", "Course"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _('Add Students'),
|
||||
"route": ["List", "Student"]
|
||||
}
|
||||
]
|
||||
),
|
||||
frappe._dict(
|
||||
action_name='Add Instructors',
|
||||
domains=["Education"],
|
||||
title=_("Instructor"),
|
||||
help=_("People who teach at your organisation"),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break", "show_section_border": 1},
|
||||
{"fieldtype":"Data", "fieldname":"instructor", "label":_("Instructor"), "placeholder": _("Instructor Name")},
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_instructor",
|
||||
done_state_title=_("Go to Instructors"),
|
||||
done_state_title_route=["List", "Instructor"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _('Student Batches'),
|
||||
"route": ["List", "Student Batch"]
|
||||
}
|
||||
]
|
||||
),
|
||||
frappe._dict(
|
||||
action_name='Add Rooms',
|
||||
domains=["Education"],
|
||||
title=_("Room"),
|
||||
help=_("Classrooms/ Laboratories etc where lectures can be scheduled."),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break", "show_section_border": 1},
|
||||
{"fieldtype":"Data", "fieldname":"room", "label":_("Room")},
|
||||
{"fieldtype":"Column Break"},
|
||||
{"fieldtype":"Int", "fieldname":"room_capacity", "label":_("Room Capacity"), "static": 1},
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_room",
|
||||
done_state_title=_("Go to Rooms"),
|
||||
done_state_title_route=["List", "Room"],
|
||||
help_links=[]
|
||||
),
|
||||
# Education slides end
|
||||
|
||||
frappe._dict(
|
||||
action_name='Add Users',
|
||||
title=_("Add Users"),
|
||||
help=_("Add users to your organization, other than yourself."),
|
||||
fields=[
|
||||
{"fieldtype":"Section Break"},
|
||||
{"fieldtype":"Data", "fieldname":"user_email", "label":_("Email ID"),
|
||||
"placeholder":_("user@example.com"), "options": "Email", "static": 1},
|
||||
{"fieldtype":"Column Break"},
|
||||
{"fieldtype":"Data", "fieldname":"user_fullname",
|
||||
"label":_("Full Name"), "static": 1},
|
||||
],
|
||||
add_more=1, max_count=3, mandatory_entry=1,
|
||||
submit_method="erpnext.utilities.user_progress_utils.create_users",
|
||||
done_state_title=_("Go to Users"),
|
||||
done_state_title_route=["List", "User"],
|
||||
help_links=[
|
||||
{
|
||||
"label": _('Learn More'),
|
||||
"url": ["https://erpnext.com/docs/user/manual/en/setting-up/users-and-permissions"]
|
||||
},
|
||||
{
|
||||
"label": _('Users and Permissions'),
|
||||
"video_id": "8Slw1hsTmUI"
|
||||
},
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
def get_user_progress_slides():
|
||||
slides = []
|
||||
slide_settings = get_slide_settings()
|
||||
|
||||
domains = frappe.get_active_domains()
|
||||
for s in slide_settings:
|
||||
if not s.domains or any(d in domains for d in s.domains):
|
||||
s.mark_as_done_method = "erpnext.setup.doctype.setup_progress.setup_progress.set_action_completed_state"
|
||||
s.done = get_action_completed_state(s.action_name) or 0
|
||||
slides.append(s)
|
||||
|
||||
return slides
|
||||
|
||||
Reference in New Issue
Block a user