From 48cccca9af26a755d4134a5a5537fbb332f712e3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 6 Aug 2015 15:37:01 +0530 Subject: [PATCH] [minor] add close button in opportunity and project links in customer --- erpnext/crm/doctype/opportunity/opportunity.js | 18 ++++++++++++++++-- erpnext/selling/doctype/customer/customer.js | 3 +++ erpnext/selling/doctype/customer/customer.py | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 6156dcf567..edaa15144f 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -80,9 +80,23 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.status!=="Quotation") cur_frm.add_custom_button(__('Opportunity Lost'), cur_frm.cscript['Declare Opportunity Lost'], "icon-remove", "btn-default"); - - } + + var frm = cur_frm; + if(frm.perm[0].write && doc.docstatus==0) { + if(frm.doc.status==="Open") { + frm.add_custom_button("Close", function() { + frm.set_value("status", "Closed"); + frm.save(); + }); + } else { + frm.add_custom_button("Reopen", function() { + frm.set_value("status", "Open"); + frm.save(); + }); + } + } + } cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 1f9a12bdd3..ac0f6366cd 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -46,6 +46,7 @@ cur_frm.cscript.setup_dashboard = function(doc) { cur_frm.dashboard.add_doctype_badge("Sales Order", "customer"); cur_frm.dashboard.add_doctype_badge("Delivery Note", "customer"); cur_frm.dashboard.add_doctype_badge("Sales Invoice", "customer"); + cur_frm.dashboard.add_doctype_badge("Project", "customer"); return frappe.call({ type: "GET", @@ -62,6 +63,8 @@ cur_frm.cscript.setup_dashboard = function(doc) { + ' / ' + __("Unpaid") + ": " + format_currency(r.message.total_unpaid, r.message["company_currency"][0]) + ''); + } else { + cur_frm.dashboard.set_headline(""); } } cur_frm.dashboard.set_badge_count(r.message); diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index f82e2fbeeb..fe68966f5f 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -119,7 +119,8 @@ def get_dashboard_info(customer): frappe.msgprint(_("Not permitted"), raise_exception=True) out = {} - for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: + for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", + "Sales Invoice", "Project"]: out[doctype] = frappe.db.get_value(doctype, {"customer": customer, "docstatus": ["!=", 2] }, "count(*)")