From e1e25a0c9d87abb4b92fe053876ac73f465b7649 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Thu, 16 Feb 2017 19:36:59 +0530 Subject: [PATCH 1/2] [minor] auto close opportunity after 7 days --- erpnext/crm/doctype/opportunity/opportunity.py | 10 ++++++++++ erpnext/hooks.py | 1 + erpnext/patches.txt | 3 ++- erpnext/public/js/utils/party.js | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index 301dc825e0..be857b5580 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -245,3 +245,13 @@ def set_multiple_status(names, status): opp = frappe.get_doc("Opportunity", name) opp.status = status opp.save() + +def auto_close_opportunity(): + """ auto close the `Replied` Opportunities after 7 days """ + opportunities = frappe.db.sql(""" select name from tabOpportunity where status='Replied' and + modifiedmodified") \ No newline at end of file diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js index a1d200f6ef..35d0b4203f 100644 --- a/erpnext/public/js/utils/party.js +++ b/erpnext/public/js/utils/party.js @@ -129,7 +129,7 @@ erpnext.utils.get_contact_details = function(frm) { if(frm.doc["contact_person"]) { frappe.call({ - method: "erpnext.utilities.doctype.contact.contact.get_contact_details", + method: "frappe.email.doctype.contact.contact.get_contact_details", args: {contact: frm.doc.contact_person }, callback: function(r) { if(r.message) From 90818080b18c6593512b373178cd2cbbb1cb9971 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Fri, 17 Feb 2017 14:56:00 +0530 Subject: [PATCH 2/2] [minor] Configured Auto Close days for Opportunity and Issue --- .../crm/doctype/opportunity/opportunity.py | 4 +- erpnext/patches.txt | 2 +- .../patches/v7_2/setup_auto_close_settings.py | 18 ++++ .../selling_settings/selling_settings.json | 75 ++++++++++++++- erpnext/support/doctype/issue/issue.py | 4 +- .../doctype/support_settings/__init__.py | 0 .../support_settings/support_settings.js | 8 ++ .../support_settings/support_settings.json | 92 +++++++++++++++++++ .../support_settings/support_settings.py | 10 ++ 9 files changed, 208 insertions(+), 5 deletions(-) create mode 100644 erpnext/patches/v7_2/setup_auto_close_settings.py create mode 100644 erpnext/support/doctype/support_settings/__init__.py create mode 100644 erpnext/support/doctype/support_settings/support_settings.js create mode 100644 erpnext/support/doctype/support_settings/support_settings.json create mode 100644 erpnext/support/doctype/support_settings/support_settings.py diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index be857b5580..786a36cf6d 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -248,8 +248,10 @@ def set_multiple_status(names, status): def auto_close_opportunity(): """ auto close the `Replied` Opportunities after 7 days """ + auto_close_after_days = frappe.db.get_value("Support Settings", "Support Settings", "close_opportunity_after_days") or 15 + opportunities = frappe.db.sql(""" select name from tabOpportunity where status='Replied' and - modifiedmodified") \ No newline at end of file +erpnext.patches.v7_2.setup_auto_close_settings \ No newline at end of file diff --git a/erpnext/patches/v7_2/setup_auto_close_settings.py b/erpnext/patches/v7_2/setup_auto_close_settings.py new file mode 100644 index 0000000000..4eef2b9c8a --- /dev/null +++ b/erpnext/patches/v7_2/setup_auto_close_settings.py @@ -0,0 +1,18 @@ +# 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 + +def execute(): + # update the selling settings and set the close_opportunity_after_days + frappe.reload_doc("selling", "doctype", "selling_settings") + frappe.db.set_value("Selling Settings", "Selling Settings", "close_opportunity_after_days", 15) + + # Auto close Replied opportunity + frappe.db.sql("""update `tabOpportunity` set status='Closed' where status='Replied' + and date_sub(curdate(), interval 15 Day)>modified""") + + # create Support Settings doctype and update close_issue_after_days + frappe.reload_doc("support", "doctype", "support_settings") + frappe.db.set_value("Support Settings", "Support Settings", "close_issue_after_days", 7) \ No newline at end of file diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.json b/erpnext/selling/doctype/selling_settings/selling_settings.json index f1bfe95e90..11b83c68e5 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.json +++ b/erpnext/selling/doctype/selling_settings/selling_settings.json @@ -24,7 +24,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Customer Naming By", "length": 0, "no_copy": 0, @@ -33,6 +35,7 @@ "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, @@ -50,7 +53,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Campaign Naming By", "length": 0, "no_copy": 0, @@ -59,6 +64,7 @@ "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, @@ -77,7 +83,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Default Customer Group", "length": 0, "no_copy": 0, @@ -86,6 +94,7 @@ "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, @@ -104,7 +113,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Default Territory", "length": 0, "no_copy": 0, @@ -113,6 +124,7 @@ "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, @@ -130,7 +142,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Default Price List", "length": 0, "no_copy": 0, @@ -139,6 +153,38 @@ "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_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "15", + "description": "Auto close Opportunity after 15 days", + "fieldname": "close_opportunity_after_days", + "fieldtype": "Int", + "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": "Close Opportunity After Days", + "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, @@ -156,13 +202,16 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "length": 0, "no_copy": 0, "permlevel": 0, "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, @@ -180,7 +229,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Sales Order Required", "length": 0, "no_copy": 0, @@ -189,6 +240,7 @@ "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, @@ -206,7 +258,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Delivery Note Required", "length": 0, "no_copy": 0, @@ -215,6 +269,7 @@ "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, @@ -232,7 +287,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Maintain Same Rate Throughout Sales Cycle", "length": 0, "no_copy": 0, @@ -240,6 +297,7 @@ "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, @@ -257,7 +315,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Allow user to edit Price List Rate in transactions", "length": 0, "no_copy": 0, @@ -265,6 +325,7 @@ "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, @@ -282,7 +343,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Allow Item to be added multiple times in a transaction", "length": 0, "no_copy": 0, @@ -291,6 +354,7 @@ "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, @@ -308,7 +372,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Allow multiple Sales Orders against a Customer's Purchase Order", "length": 0, "no_copy": 0, @@ -317,6 +383,7 @@ "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, @@ -334,7 +401,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "label": "Validate Selling Price for Item against Purchase Rate or Valuation Rate", "length": 0, "no_copy": 0, @@ -343,6 +412,7 @@ "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, @@ -361,7 +431,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2016-10-20 08:17:45.621151", + "modified": "2017-02-17 13:06:03.520385", "modified_by": "Administrator", "module": "Selling", "name": "Selling Settings", @@ -377,7 +447,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -392,7 +461,9 @@ "quick_entry": 0, "read_only": 0, "read_only_onload": 0, + "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py index 2798f70226..a1f80770e2 100644 --- a/erpnext/support/doctype/issue/issue.py +++ b/erpnext/support/doctype/issue/issue.py @@ -82,8 +82,10 @@ def set_status(name, status): def auto_close_tickets(): """ auto close the replied support tickets after 7 days """ + auto_close_after_days = frappe.db.get_value("Support Settings", "Support Settings", "close_issue_after_days") or 7 + issues = frappe.db.sql(""" select name from tabIssue where status='Replied' and - modified