mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
report lost opportunity
This commit is contained in:
@@ -6,7 +6,7 @@ from frappe import _
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns, data = get_columns(), get_leads(filters)
|
columns, data = get_columns(), get_data(filters)
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
@@ -117,7 +117,7 @@ def get_columns():
|
|||||||
]
|
]
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
def get_leads(filters):
|
def get_data(filters):
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
SELECT
|
SELECT
|
||||||
`tabLead`.name,
|
`tabLead`.name,
|
||||||
|
|||||||
41
erpnext/crm/report/lost_opportunity/lost_opportunity.js
Normal file
41
erpnext/crm/report/lost_opportunity/lost_opportunity.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
frappe.query_reports["Lost Opportunity"] = {
|
||||||
|
"filters": [
|
||||||
|
{
|
||||||
|
"fieldname":"company",
|
||||||
|
"label": __("Company"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Company",
|
||||||
|
"default": frappe.defaults.get_user_default("Company"),
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"opportunity_from",
|
||||||
|
"label": __("Opportunity From"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "DocType",
|
||||||
|
"get_query": function() {
|
||||||
|
return {
|
||||||
|
"filters": {
|
||||||
|
"name": ["in", ["Customer", "Lead"]],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"party_name",
|
||||||
|
"label": __("Party"),
|
||||||
|
"fieldtype": "Dynamic Link",
|
||||||
|
"options": "opportunity_from"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"contact_by",
|
||||||
|
"label": __("Next Contact By"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "User"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"add_total_row": 0,
|
"add_total_row": 0,
|
||||||
"creation": "2018-12-31 16:30:57.188837",
|
"creation": "2018-12-31 16:30:57.188837",
|
||||||
|
"disable_prepared_report": 0,
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"json": "{\"order_by\": \"`tabOpportunity`.`modified` desc\", \"filters\": [[\"Opportunity\", \"status\", \"=\", \"Lost\"]], \"fields\": [[\"name\", \"Opportunity\"], [\"opportunity_from\", \"Opportunity\"], [\"party_name\", \"Opportunity\"], [\"customer_name\", \"Opportunity\"], [\"opportunity_type\", \"Opportunity\"], [\"status\", \"Opportunity\"], [\"contact_by\", \"Opportunity\"], [\"docstatus\", \"Opportunity\"], [\"lost_reason\", \"Lost Reason Detail\"]], \"add_totals_row\": 0, \"add_total_row\": 0, \"page_length\": 20}",
|
"json": "{\"order_by\": \"`tabOpportunity`.`modified` desc\", \"filters\": [[\"Opportunity\", \"status\", \"=\", \"Lost\"]], \"fields\": [[\"name\", \"Opportunity\"], [\"opportunity_from\", \"Opportunity\"], [\"party_name\", \"Opportunity\"], [\"customer_name\", \"Opportunity\"], [\"opportunity_type\", \"Opportunity\"], [\"status\", \"Opportunity\"], [\"contact_by\", \"Opportunity\"], [\"docstatus\", \"Opportunity\"], [\"lost_reason\", \"Lost Reason Detail\"]], \"add_totals_row\": 0, \"add_total_row\": 0, \"page_length\": 20}",
|
||||||
"modified": "2019-06-26 16:33:08.083618",
|
"modified": "2020-07-29 15:49:02.848845",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "CRM",
|
"module": "CRM",
|
||||||
"name": "Lost Opportunity",
|
"name": "Lost Opportunity",
|
||||||
@@ -15,7 +16,7 @@
|
|||||||
"prepared_report": 0,
|
"prepared_report": 0,
|
||||||
"ref_doctype": "Opportunity",
|
"ref_doctype": "Opportunity",
|
||||||
"report_name": "Lost Opportunity",
|
"report_name": "Lost Opportunity",
|
||||||
"report_type": "Report Builder",
|
"report_type": "Script Report",
|
||||||
"roles": [
|
"roles": [
|
||||||
{
|
{
|
||||||
"role": "Sales User"
|
"role": "Sales User"
|
||||||
|
|||||||
86
erpnext/crm/report/lost_opportunity/lost_opportunity.py
Normal file
86
erpnext/crm/report/lost_opportunity/lost_opportunity.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from frappe import _
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute(filters=None):
|
||||||
|
columns, data = get_columns(), get_data(filters)
|
||||||
|
return columns, data
|
||||||
|
|
||||||
|
def get_columns():
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
"label": _("Opportunity"),
|
||||||
|
"fieldname": "name",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Opportunity",
|
||||||
|
"width": 170,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Opportunity From"),
|
||||||
|
"fieldname": "opportunity_from",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "DocType",
|
||||||
|
"width": 130
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Party"),
|
||||||
|
"fieldname":"party_name",
|
||||||
|
"fieldtype": "Dynamic Link",
|
||||||
|
"options": "opportunity_from",
|
||||||
|
"width": 160
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Customer/Lead Name"),
|
||||||
|
"fieldname":"customer_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Opportunity Type"),
|
||||||
|
"fieldname": "opportunity_type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 130
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Next Contact By"),
|
||||||
|
"fieldname": "contact_by",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "User",
|
||||||
|
"width": 120
|
||||||
|
}
|
||||||
|
]
|
||||||
|
return columns
|
||||||
|
|
||||||
|
def get_data(filters):
|
||||||
|
return frappe.db.sql("""
|
||||||
|
SELECT
|
||||||
|
`tabOpportunity`.name,
|
||||||
|
`tabOpportunity`.opportunity_from,
|
||||||
|
`tabOpportunity`.party_name,
|
||||||
|
`tabOpportunity`.customer_name,
|
||||||
|
`tabOpportunity`.opportunity_type,
|
||||||
|
`tabOpportunity`.contact_by
|
||||||
|
FROM
|
||||||
|
`tabOpportunity`
|
||||||
|
WHERE
|
||||||
|
status = 'Lost' and company = %(company)s
|
||||||
|
{conditions}
|
||||||
|
ORDER BY
|
||||||
|
creation asc """.format(conditions=get_conditions(filters)), filters, as_dict=1)
|
||||||
|
|
||||||
|
def get_conditions(filters) :
|
||||||
|
conditions = []
|
||||||
|
|
||||||
|
if filters.get("opportunity_from"):
|
||||||
|
conditions.append("opportunity_from=%(opportunity_from)s")
|
||||||
|
|
||||||
|
if filters.get("party_name"):
|
||||||
|
conditions.append("party_name=%(party_name)s")
|
||||||
|
|
||||||
|
if filters.get("contact_by"):
|
||||||
|
conditions.append("contact_by=%(contact_by)s")
|
||||||
|
|
||||||
|
return " and {}".format(" and ".join(conditions)) if conditions else ""
|
||||||
Reference in New Issue
Block a user