Progress fixes (#10710)

* [progress] sales target slide

* [fix] rerun patch for sales target slide
This commit is contained in:
Prateeksha Singh 2017-09-13 18:41:01 +05:30 committed by Rushabh Mehta
parent c050c6945c
commit 242218d2b7
7 changed files with 121 additions and 9 deletions

View File

@ -436,7 +436,7 @@ erpnext.patches.v8_7.add_more_gst_fields
erpnext.patches.v8_7.fix_purchase_receipt_status
erpnext.patches.v8_6.rename_bom_update_tool
erpnext.patches.v8_7.set_offline_in_pos_settings #11-09-17
erpnext.patches.v8_9.add_setup_progress_actions
erpnext.patches.v8_9.add_setup_progress_actions #08-09-2017
erpnext.patches.v8_9.rename_company_sales_target_field
erpnext.patches.v8_8.set_bom_rate_as_per_uom
erpnext.patches.v8_7.make_subscription_from_recurring_data

View File

@ -11,6 +11,10 @@ def execute():
actions = [
{"action_name": _("Add Company"), "action_doctype": "Company", "min_doc_count": 1, "is_completed": 1,
"domains": '[]' },
{"action_name": _("Set Sales Target"), "action_doctype": "Company", "min_doc_count": 99,
"action_document": frappe.defaults.get_defaults().get("company") or '',
"action_field": "monthly_sales_target", "is_completed": 0,
"domains": '["Manufacturing", "Services", "Retail", "Distribution"]' },
{"action_name": _("Add Customers"), "action_doctype": "Customer", "min_doc_count": 1, "is_completed": 0,
"domains": '["Manufacturing", "Services", "Retail", "Distribution"]' },
{"action_name": _("Add Suppliers"), "action_doctype": "Supplier", "min_doc_count": 1, "is_completed": 0,
@ -30,6 +34,7 @@ def execute():
]
setup_progress = frappe.get_doc("Setup Progress", "Setup Progress")
setup_progress.actions = []
for action in actions:
setup_progress.append("actions", action)

View File

@ -24,10 +24,21 @@ def update_action_completed_state(action_name):
if d.action_name == action_name][0]
update_action(action_table_doc)
def update_action(action_table_doc):
if not action_table_doc.is_completed and frappe.db.count(action_table_doc.action_doctype) >= action_table_doc.min_doc_count:
action_table_doc.is_completed = 1
action_table_doc.save()
def update_action(doc):
doctype = doc.action_doctype
docname = doc.action_document
field = doc.action_field
if not doc.is_completed:
if doc.min_doc_count:
if frappe.db.count(doctype) >= doc.min_doc_count:
doc.is_completed = 1
doc.save()
if docname and field:
d = frappe.get_doc(doctype, docname)
if d.get(field):
doc.is_completed = 1
doc.save()
def update_domain_actions(domain):
for d in get_setup_progress().actions:

View File

@ -73,6 +73,67 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "action_document",
"fieldtype": "Dynamic Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Action Document",
"length": 0,
"no_copy": 0,
"options": "action_doctype",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "action_field",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Action Field",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -174,7 +235,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-08-28 17:44:58.008526",
"modified": "2017-09-01 14:34:59.685730",
"modified_by": "Administrator",
"module": "Setup",
"name": "Setup Progress Action",

View File

@ -25,6 +25,10 @@ def install(country=None):
{'doctype': "Setup Progress", "actions": [
{"action_name": _("Add Company"), "action_doctype": "Company", "min_doc_count": 1, "is_completed": 1,
"domains": '[]' },
{"action_name": _("Set Sales Target"), "action_doctype": "Company", "min_doc_count": 99,
"action_document": frappe.defaults.get_defaults().get("company") or '',
"action_field": "monthly_sales_target", "is_completed": 0,
"domains": '["Manufacturing", "Services", "Retail", "Distribution"]' },
{"action_name": _("Add Customers"), "action_doctype": "Customer", "min_doc_count": 1, "is_completed": 0,
"domains": '["Manufacturing", "Services", "Retail", "Distribution"]' },
{"action_name": _("Add Suppliers"), "action_doctype": "Supplier", "min_doc_count": 1, "is_completed": 0,

View File

@ -9,6 +9,14 @@ def get_slide_settings():
defaults = frappe.defaults.get_defaults()
domain = frappe.db.get_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"][0]
item.action_document = company
item.save()
doc.save()
# Initial state of slides
return [
frappe._dict(
@ -29,12 +37,29 @@ def get_slide_settings():
"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 + ")")},
],
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.org/docs/user/manual/en/setting-up/setting-company-sales-goal"]
}
]
),
frappe._dict(
action_name='Add Customers',
domains=('Manufacturing', 'Services', 'Retail', 'Distribution'),
icon="fa fa-group",
title=_("Add Customers"),
help=_("List a few of your customers. They could be organizations or individuals."),
fields=[

View File

@ -8,6 +8,12 @@ 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)