[minor] auto close opportunity after 7 days

This commit is contained in:
mbauskar 2017-02-16 19:36:59 +05:30
parent de45b0eddc
commit e1e25a0c9d
4 changed files with 14 additions and 2 deletions

View File

@ -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
modified<DATE_SUB(CURDATE(), INTERVAL 7 DAY) """, as_dict=True)
for opportunity in opportunities:
doc = frappe.get_doc("Opportunity", opportunity.get("name"))
doc.status = "Closed"
doc.save(ignore_permissions=True)

View File

@ -164,6 +164,7 @@ scheduler_events = {
"erpnext.stock.reorder_item.reorder_item",
"erpnext.setup.doctype.email_digest.email_digest.send",
"erpnext.support.doctype.issue.issue.auto_close_tickets",
"erpnext.crm.doctype.opportunity.opportunity.auto_close_opportunity",
"erpnext.controllers.accounts_controller.update_invoice_status",
"erpnext.accounts.doctype.fiscal_year.fiscal_year.auto_create_fiscal_year",
"erpnext.hr.doctype.employee.employee.send_birthday_reminders",

View File

@ -371,3 +371,4 @@ erpnext.patches.v7_2.update_guardian_name_in_student_master
erpnext.patches.v7_2.update_abbr_in_salary_slips
erpnext.patches.v7_2.rename_evaluation_criteria
erpnext.patches.v7_2.update_party_type
execute:frappe.db.sql("update `tabOpportunity` set status='Closed' where status='Replied' and date_sub(curdate(), interval 7 Day)>modified")

View File

@ -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)