Merge branch 'develop' into fix_indentation

This commit is contained in:
sahil28297 2019-09-17 17:08:16 +05:30 committed by GitHub
commit c1930fa64d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 593 additions and 1607 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
import frappe import frappe
import requests import requests
from frappe import _
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call # api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call # api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call
@ -7,19 +8,24 @@ import requests
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def handle_incoming_call(**kwargs): def handle_incoming_call(**kwargs):
exotel_settings = get_exotel_settings() try:
if not exotel_settings.enabled: return exotel_settings = get_exotel_settings()
if not exotel_settings.enabled: return
call_payload = kwargs call_payload = kwargs
status = call_payload.get('Status') status = call_payload.get('Status')
if status == 'free': if status == 'free':
return return
call_log = get_call_log(call_payload) call_log = get_call_log(call_payload)
if not call_log: if not call_log:
create_call_log(call_payload) create_call_log(call_payload)
else: else:
update_call_log(call_payload, call_log=call_log) update_call_log(call_payload, call_log=call_log)
except Exception as e:
frappe.db.rollback()
frappe.log_error(title=_('Error in Exotel incoming call'))
frappe.db.commit()
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def handle_end_call(**kwargs): def handle_end_call(**kwargs):
@ -101,4 +107,4 @@ def get_exotel_endpoint(action):
api_token=settings.api_token, api_token=settings.api_token,
sid=settings.account_sid, sid=settings.account_sid,
action=action action=action
) )

View File

@ -635,3 +635,4 @@ erpnext.patches.v12_0.remove_bank_remittance_custom_fields
erpnext.patches.v12_0.generate_leave_ledger_entries erpnext.patches.v12_0.generate_leave_ledger_entries
erpnext.patches.v12_0.move_credit_limit_to_customer_credit_limit erpnext.patches.v12_0.move_credit_limit_to_customer_credit_limit
erpnext.patches.v12_0.add_variant_of_in_item_attribute_table erpnext.patches.v12_0.add_variant_of_in_item_attribute_table
erpnext.patches.v12_0.create_default_energy_point_rules

View File

@ -0,0 +1,6 @@
import frappe
from erpnext.setup.install import create_default_energy_point_rules
def execute():
frappe.reload_doc('social', 'doctype', 'energy_point_rule')
create_default_energy_point_rules()

View File

@ -1,381 +1,391 @@
{ {
"allow_import": 1, "allow_import": 1,
"autoname": "TASK-.YYYY.-.#####", "autoname": "TASK-.YYYY.-.#####",
"creation": "2013-01-29 19:25:50", "creation": "2013-01-29 19:25:50",
"doctype": "DocType", "doctype": "DocType",
"document_type": "Setup", "document_type": "Setup",
"field_order": [ "engine": "InnoDB",
"subject", "field_order": [
"project", "subject",
"issue", "project",
"type", "issue",
"is_group", "type",
"column_break0", "is_group",
"status", "column_break0",
"priority", "status",
"task_weight", "priority",
"color", "task_weight",
"parent_task", "completed_by",
"sb_timeline", "color",
"exp_start_date", "parent_task",
"expected_time", "sb_timeline",
"column_break_11", "exp_start_date",
"exp_end_date", "expected_time",
"progress", "column_break_11",
"is_milestone", "exp_end_date",
"sb_details", "progress",
"description", "is_milestone",
"sb_depends_on", "sb_details",
"depends_on", "description",
"depends_on_tasks", "sb_depends_on",
"sb_actual", "depends_on",
"act_start_date", "depends_on_tasks",
"actual_time", "sb_actual",
"column_break_15", "act_start_date",
"act_end_date", "actual_time",
"sb_costing", "column_break_15",
"total_costing_amount", "act_end_date",
"total_expense_claim", "sb_costing",
"column_break_20", "total_costing_amount",
"total_billing_amount", "total_expense_claim",
"sb_more_info", "column_break_20",
"review_date", "total_billing_amount",
"closing_date", "sb_more_info",
"column_break_22", "review_date",
"department", "closing_date",
"company", "column_break_22",
"lft", "department",
"rgt", "company",
"old_parent" "lft",
], "rgt",
"fields": [ "old_parent"
{ ],
"fieldname": "subject", "fields": [
"fieldtype": "Data", {
"in_global_search": 1, "fieldname": "subject",
"label": "Subject", "fieldtype": "Data",
"reqd": 1, "in_global_search": 1,
"search_index": 1, "in_standard_filter": 1,
"in_standard_filter": 1 "label": "Subject",
}, "reqd": 1,
{ "search_index": 1
"bold": 1, },
"fieldname": "project", {
"fieldtype": "Link", "bold": 1,
"in_global_search": 1, "fieldname": "project",
"in_list_view": 1, "fieldtype": "Link",
"in_standard_filter": 1, "in_global_search": 1,
"label": "Project", "in_list_view": 1,
"oldfieldname": "project", "in_standard_filter": 1,
"oldfieldtype": "Link", "label": "Project",
"options": "Project", "oldfieldname": "project",
"remember_last_selected_value": 1, "oldfieldtype": "Link",
"search_index": 1 "options": "Project",
}, "remember_last_selected_value": 1,
{ "search_index": 1
"fieldname": "issue", },
"fieldtype": "Link", {
"label": "Issue", "fieldname": "issue",
"options": "Issue" "fieldtype": "Link",
}, "label": "Issue",
{ "options": "Issue"
"fieldname": "type", },
"fieldtype": "Link", {
"label": "Type", "fieldname": "type",
"options": "Task Type" "fieldtype": "Link",
}, "label": "Type",
{ "options": "Task Type"
"bold": 1, },
"default": "0", {
"fieldname": "is_group", "bold": 1,
"fieldtype": "Check", "default": "0",
"in_list_view": 1, "fieldname": "is_group",
"label": "Is Group" "fieldtype": "Check",
}, "in_list_view": 1,
{ "label": "Is Group"
"fieldname": "column_break0", },
"fieldtype": "Column Break", {
"oldfieldtype": "Column Break", "fieldname": "column_break0",
"print_width": "50%", "fieldtype": "Column Break",
"width": "50%" "oldfieldtype": "Column Break",
}, "print_width": "50%",
{ "width": "50%"
"bold": 1, },
"fieldname": "status", {
"fieldtype": "Select", "bold": 1,
"in_list_view": 1, "fieldname": "status",
"in_standard_filter": 1, "fieldtype": "Select",
"label": "Status", "in_list_view": 1,
"no_copy": 1, "in_standard_filter": 1,
"oldfieldname": "status", "label": "Status",
"oldfieldtype": "Select", "no_copy": 1,
"options": "Open\nWorking\nPending Review\nOverdue\nCompleted\nCancelled" "oldfieldname": "status",
}, "oldfieldtype": "Select",
{ "options": "Open\nWorking\nPending Review\nOverdue\nCompleted\nCancelled"
"fieldname": "priority", },
"fieldtype": "Select", {
"in_list_view": 1, "fieldname": "priority",
"in_standard_filter": 1, "fieldtype": "Select",
"label": "Priority", "in_list_view": 1,
"oldfieldname": "priority", "in_standard_filter": 1,
"oldfieldtype": "Select", "label": "Priority",
"options": "Low\nMedium\nHigh\nUrgent", "oldfieldname": "priority",
"search_index": 1 "oldfieldtype": "Select",
}, "options": "Low\nMedium\nHigh\nUrgent",
{ "search_index": 1
"fieldname": "color", },
"fieldtype": "Color", {
"label": "Color" "fieldname": "color",
}, "fieldtype": "Color",
{ "label": "Color"
"bold": 1, },
"fieldname": "parent_task", {
"fieldtype": "Link", "bold": 1,
"ignore_user_permissions": 1, "fieldname": "parent_task",
"label": "Parent Task", "fieldtype": "Link",
"options": "Task", "ignore_user_permissions": 1,
"search_index": 1 "label": "Parent Task",
}, "options": "Task",
{ "search_index": 1
"collapsible": 1, },
"collapsible_depends_on": "eval:doc.__islocal", {
"fieldname": "sb_timeline", "collapsible": 1,
"fieldtype": "Section Break", "collapsible_depends_on": "eval:doc.__islocal",
"label": "Timeline" "fieldname": "sb_timeline",
}, "fieldtype": "Section Break",
{ "label": "Timeline"
"fieldname": "exp_start_date", },
"fieldtype": "Date", {
"label": "Expected Start Date", "fieldname": "exp_start_date",
"oldfieldname": "exp_start_date", "fieldtype": "Date",
"oldfieldtype": "Date" "label": "Expected Start Date",
}, "oldfieldname": "exp_start_date",
{ "oldfieldtype": "Date"
"default": "0", },
"fieldname": "expected_time", {
"fieldtype": "Float", "default": "0",
"label": "Expected Time (in hours)", "fieldname": "expected_time",
"oldfieldname": "exp_total_hrs", "fieldtype": "Float",
"oldfieldtype": "Data" "label": "Expected Time (in hours)",
}, "oldfieldname": "exp_total_hrs",
{ "oldfieldtype": "Data"
"fetch_from": "type.weight", },
"fieldname": "task_weight", {
"fieldtype": "Float", "fetch_from": "type.weight",
"label": "Weight" "fieldname": "task_weight",
}, "fieldtype": "Float",
{ "label": "Weight"
"fieldname": "column_break_11", },
"fieldtype": "Column Break" {
}, "fieldname": "column_break_11",
{ "fieldtype": "Column Break"
"bold": 1, },
"fieldname": "exp_end_date", {
"fieldtype": "Date", "bold": 1,
"label": "Expected End Date", "fieldname": "exp_end_date",
"oldfieldname": "exp_end_date", "fieldtype": "Date",
"oldfieldtype": "Date", "label": "Expected End Date",
"search_index": 1 "oldfieldname": "exp_end_date",
}, "oldfieldtype": "Date",
{ "search_index": 1
"fieldname": "progress", },
"fieldtype": "Percent", {
"label": "% Progress" "fieldname": "progress",
}, "fieldtype": "Percent",
{ "label": "% Progress"
"fieldname": "is_milestone", },
"fieldtype": "Check", {
"in_list_view": 1, "default": "0",
"label": "Is Milestone" "fieldname": "is_milestone",
}, "fieldtype": "Check",
{ "in_list_view": 1,
"fieldname": "sb_details", "label": "Is Milestone"
"fieldtype": "Section Break", },
"label": "Details", {
"oldfieldtype": "Section Break" "fieldname": "sb_details",
}, "fieldtype": "Section Break",
{ "label": "Details",
"fieldname": "description", "oldfieldtype": "Section Break"
"fieldtype": "Text Editor", },
"in_preview": 1, {
"label": "Task Description", "fieldname": "description",
"oldfieldname": "description", "fieldtype": "Text Editor",
"oldfieldtype": "Text Editor", "in_preview": 1,
"print_width": "300px", "label": "Task Description",
"width": "300px" "oldfieldname": "description",
}, "oldfieldtype": "Text Editor",
{ "print_width": "300px",
"fieldname": "sb_depends_on", "width": "300px"
"fieldtype": "Section Break", },
"label": "Dependencies", {
"oldfieldtype": "Section Break" "fieldname": "sb_depends_on",
}, "fieldtype": "Section Break",
{ "label": "Dependencies",
"fieldname": "depends_on", "oldfieldtype": "Section Break"
"fieldtype": "Table", },
"label": "Dependent Tasks", {
"options": "Task Depends On" "fieldname": "depends_on",
}, "fieldtype": "Table",
{ "label": "Dependent Tasks",
"fieldname": "depends_on_tasks", "options": "Task Depends On"
"fieldtype": "Code", },
"hidden": 1, {
"label": "Depends on Tasks", "fieldname": "depends_on_tasks",
"read_only": 1 "fieldtype": "Code",
}, "hidden": 1,
{ "label": "Depends on Tasks",
"fieldname": "sb_actual", "read_only": 1
"fieldtype": "Section Break", },
"oldfieldtype": "Column Break", {
"print_width": "50%", "fieldname": "sb_actual",
"width": "50%" "fieldtype": "Section Break",
}, "oldfieldtype": "Column Break",
{ "print_width": "50%",
"fieldname": "act_start_date", "width": "50%"
"fieldtype": "Date", },
"label": "Actual Start Date (via Time Sheet)", {
"oldfieldname": "act_start_date", "fieldname": "act_start_date",
"oldfieldtype": "Date", "fieldtype": "Date",
"read_only": 1 "label": "Actual Start Date (via Time Sheet)",
}, "oldfieldname": "act_start_date",
{ "oldfieldtype": "Date",
"fieldname": "actual_time", "read_only": 1
"fieldtype": "Float", },
"label": "Actual Time (in hours)", {
"read_only": 1 "fieldname": "actual_time",
}, "fieldtype": "Float",
{ "label": "Actual Time (in hours)",
"fieldname": "column_break_15", "read_only": 1
"fieldtype": "Column Break" },
}, {
{ "fieldname": "column_break_15",
"fieldname": "act_end_date", "fieldtype": "Column Break"
"fieldtype": "Date", },
"label": "Actual End Date (via Time Sheet)", {
"oldfieldname": "act_end_date", "fieldname": "act_end_date",
"oldfieldtype": "Date", "fieldtype": "Date",
"read_only": 1 "label": "Actual End Date (via Time Sheet)",
}, "oldfieldname": "act_end_date",
{ "oldfieldtype": "Date",
"collapsible": 1, "read_only": 1
"fieldname": "sb_costing", },
"fieldtype": "Section Break", {
"label": "Costing" "collapsible": 1,
}, "fieldname": "sb_costing",
{ "fieldtype": "Section Break",
"fieldname": "total_costing_amount", "label": "Costing"
"fieldtype": "Currency", },
"label": "Total Costing Amount (via Time Sheet)", {
"oldfieldname": "actual_budget", "fieldname": "total_costing_amount",
"oldfieldtype": "Currency", "fieldtype": "Currency",
"options": "Company:company:default_currency", "label": "Total Costing Amount (via Time Sheet)",
"read_only": 1 "oldfieldname": "actual_budget",
}, "oldfieldtype": "Currency",
{ "options": "Company:company:default_currency",
"fieldname": "total_expense_claim", "read_only": 1
"fieldtype": "Currency", },
"label": "Total Expense Claim (via Expense Claim)", {
"options": "Company:company:default_currency", "fieldname": "total_expense_claim",
"read_only": 1 "fieldtype": "Currency",
}, "label": "Total Expense Claim (via Expense Claim)",
{ "options": "Company:company:default_currency",
"fieldname": "column_break_20", "read_only": 1
"fieldtype": "Column Break" },
}, {
{ "fieldname": "column_break_20",
"fieldname": "total_billing_amount", "fieldtype": "Column Break"
"fieldtype": "Currency", },
"label": "Total Billing Amount (via Time Sheet)", {
"read_only": 1 "fieldname": "total_billing_amount",
}, "fieldtype": "Currency",
{ "label": "Total Billing Amount (via Time Sheet)",
"collapsible": 1, "read_only": 1
"fieldname": "sb_more_info", },
"fieldtype": "Section Break", {
"label": "More Info" "collapsible": 1,
}, "fieldname": "sb_more_info",
{ "fieldtype": "Section Break",
"depends_on": "eval:doc.status == \"Closed\" || doc.status == \"Pending Review\"", "label": "More Info"
"fieldname": "review_date", },
"fieldtype": "Date", {
"label": "Review Date", "depends_on": "eval:doc.status == \"Closed\" || doc.status == \"Pending Review\"",
"oldfieldname": "review_date", "fieldname": "review_date",
"oldfieldtype": "Date" "fieldtype": "Date",
}, "label": "Review Date",
{ "oldfieldname": "review_date",
"depends_on": "eval:doc.status == \"Closed\"", "oldfieldtype": "Date"
"fieldname": "closing_date", },
"fieldtype": "Date", {
"label": "Closing Date", "depends_on": "eval:doc.status == \"Closed\"",
"oldfieldname": "closing_date", "fieldname": "closing_date",
"oldfieldtype": "Date" "fieldtype": "Date",
}, "label": "Closing Date",
{ "oldfieldname": "closing_date",
"fieldname": "column_break_22", "oldfieldtype": "Date"
"fieldtype": "Column Break" },
}, {
{ "fieldname": "column_break_22",
"fieldname": "department", "fieldtype": "Column Break"
"fieldtype": "Link", },
"label": "Department", {
"options": "Department" "fieldname": "department",
}, "fieldtype": "Link",
{ "label": "Department",
"fieldname": "company", "options": "Department"
"fieldtype": "Link", },
"label": "Company", {
"options": "Company", "fieldname": "company",
"remember_last_selected_value": 1 "fieldtype": "Link",
}, "label": "Company",
{ "options": "Company",
"fieldname": "lft", "remember_last_selected_value": 1
"fieldtype": "Int", },
"hidden": 1, {
"label": "lft", "fieldname": "lft",
"read_only": 1 "fieldtype": "Int",
}, "hidden": 1,
{ "label": "lft",
"fieldname": "rgt", "read_only": 1
"fieldtype": "Int", },
"hidden": 1, {
"label": "rgt", "fieldname": "rgt",
"read_only": 1 "fieldtype": "Int",
}, "hidden": 1,
{ "label": "rgt",
"fieldname": "old_parent", "read_only": 1
"fieldtype": "Data", },
"hidden": 1, {
"ignore_user_permissions": 1, "fieldname": "old_parent",
"label": "Old Parent", "fieldtype": "Data",
"read_only": 1 "hidden": 1,
} "ignore_user_permissions": 1,
], "label": "Old Parent",
"icon": "fa fa-check", "read_only": 1
"idx": 1, },
"max_attachments": 5, {
"modified": "2019-06-19 09:51:15.599416", "fieldname": "completed_by",
"modified_by": "Administrator", "fieldtype": "Link",
"module": "Projects", "label": "Completed By",
"name": "Task", "options": "User"
"owner": "Administrator", }
"permissions": [ ],
{ "icon": "fa fa-check",
"create": 1, "idx": 1,
"delete": 1, "max_attachments": 5,
"email": 1, "modified": "2019-09-10 13:46:24.631754",
"print": 1, "modified_by": "Administrator",
"read": 1, "module": "Projects",
"report": 1, "name": "Task",
"role": "Projects User", "owner": "Administrator",
"share": 1, "permissions": [
"write": 1 {
} "create": 1,
], "delete": 1,
"search_fields": "subject", "email": 1,
"show_name_in_global_search": 1, "print": 1,
"show_preview_popup": 1, "read": 1,
"sort_order": "DESC", "report": 1,
"timeline_field": "project", "role": "Projects User",
"title_field": "subject", "share": 1,
"track_seen": 1 "write": 1
} }
],
"search_fields": "subject",
"show_name_in_global_search": 1,
"show_preview_popup": 1,
"sort_field": "modified",
"sort_order": "DESC",
"timeline_field": "project",
"title_field": "subject",
"track_seen": 1
}

View File

@ -0,0 +1,58 @@
from __future__ import unicode_literals
from frappe import _
doctype_rule_map = {
'Item': {
'points': 5,
'for_doc_event': 'New'
},
'Customer': {
'points': 5,
'for_doc_event': 'New'
},
'Supplier': {
'points': 5,
'for_doc_event': 'New'
},
'Lead': {
'points': 2,
'for_doc_event': 'New'
},
'Opportunity': {
'points': 10,
'for_doc_event': 'Custom',
'condition': 'doc.status=="Converted"',
'rule_name': _('On Converting Opportunity'),
'user_field': 'converted_by'
},
'Sales Order': {
'points': 10,
'for_doc_event': 'Submit',
'rule_name': _('On Sales Order Submission'),
'user_field': 'modified_by'
},
'Purchase Order': {
'points': 10,
'for_doc_event': 'Submit',
'rule_name': _('On Purchase Order Submission'),
'user_field': 'modified_by'
},
'Task': {
'points': 5,
'condition': 'doc.status == "Completed"',
'rule_name': _('On Task Completion'),
'user_field': 'completed_by'
}
}
def get_default_energy_point_rules():
return [{
'doctype': 'Energy Point Rule',
'reference_doctype': doctype,
'for_doc_event': rule.get('for_doc_event') or 'Custom',
'condition': rule.get('condition'),
'rule_name': rule.get('rule_name') or _('On {0} Creation').format(doctype),
'points': rule.get('points'),
'user_field': rule.get('user_field') or 'owner'
} for doctype, rule in doctype_rule_map.items()]

View File

@ -2,26 +2,26 @@ from __future__ import unicode_literals
from frappe import _ from frappe import _
doctype_list = [ doctype_list = [
'Purchase Receipt', 'Purchase Receipt',
'Purchase Invoice', 'Purchase Invoice',
'Quotation', 'Quotation',
'Sales Order', 'Sales Order',
'Delivery Note', 'Delivery Note',
'Sales Invoice' 'Sales Invoice'
] ]
def get_message(doctype): def get_message(doctype):
return _("{0} has been submitted successfully".format(_(doctype))) return _("{0} has been submitted successfully").format(_(doctype))
def get_first_success_message(doctype): def get_first_success_message(doctype):
return _("{0} has been submitted successfully".format(_(doctype))) return get_message(doctype)
def get_default_success_action(): def get_default_success_action():
return [{ return [{
'doctype': 'Success Action', 'doctype': 'Success Action',
'ref_doctype': doctype, 'ref_doctype': doctype,
'message': get_message(doctype), 'message': get_message(doctype),
'first_success_message': get_first_success_message(doctype), 'first_success_message': get_first_success_message(doctype),
'next_actions': 'new\nprint\nemail' 'next_actions': 'new\nprint\nemail'
} for doctype in doctype_list] } for doctype in doctype_list]

View File

@ -9,6 +9,7 @@ from .default_success_action import get_default_success_action
from frappe import _ from frappe import _
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
from frappe.custom.doctype.custom_field.custom_field import create_custom_field from frappe.custom.doctype.custom_field.custom_field import create_custom_field
from erpnext.setup.default_energy_point_rules import get_default_energy_point_rules
default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via default_mail_footer = """<div style="padding: 7px; text-align: right; color: #888"><small>Sent via
<a style="color: #888" href="http://erpnext.org">ERPNext</a></div>""" <a style="color: #888" href="http://erpnext.org">ERPNext</a></div>"""
@ -22,6 +23,7 @@ def after_install():
add_all_roles_to("Administrator") add_all_roles_to("Administrator")
create_default_cash_flow_mapper_templates() create_default_cash_flow_mapper_templates()
create_default_success_action() create_default_success_action()
create_default_energy_point_rules()
add_company_to_session_defaults() add_company_to_session_defaults()
frappe.db.commit() frappe.db.commit()
@ -86,6 +88,17 @@ def create_default_success_action():
doc = frappe.get_doc(success_action) doc = frappe.get_doc(success_action)
doc.insert(ignore_permissions=True) doc.insert(ignore_permissions=True)
def create_default_energy_point_rules():
for rule in get_default_energy_point_rules():
# check if any rule for ref. doctype exists
rule_exists = frappe.db.exists('Energy Point Rule', {
'reference_doctype': rule.get('reference_doctype')
})
if rule_exists: continue
doc = frappe.get_doc(rule)
doc.insert(ignore_permissions=True)
def add_company_to_session_defaults(): def add_company_to_session_defaults():
settings = frappe.get_single("Session Default Settings") settings = frappe.get_single("Session Default Settings")
settings.append("session_defaults", { settings.append("session_defaults", {