report lead detail
diff --git a/erpnext/crm/report/lead_details/lead_details.py b/erpnext/crm/report/lead_details/lead_details.py
index 079f32e..9f4ae60 100644
--- a/erpnext/crm/report/lead_details/lead_details.py
+++ b/erpnext/crm/report/lead_details/lead_details.py
@@ -69,12 +69,6 @@
"width": 120
},
{
- "label": _("Notes"),
- "fieldname": "notes",
- "fieldtype": "Data",
- "width": 120
- },
- {
"label": _("Owner"),
"fieldname": "owner",
"fieldtype": "Link",
@@ -129,7 +123,6 @@
`tabLead`.email_id,
`tabLead`.mobile_no,
`tabLead`.phone,
- `tabLead`.notes,
`tabLead`.owner,
`tabLead`.company,
concat_ws(', ',
@@ -153,12 +146,12 @@
`tabLead`.creation asc """.format(conditions=get_conditions(filters)), filters, as_dict=1)
def get_conditions(filters) :
- conditions = []
+ conditions = ""
if filters.get("territory"):
- conditions.append("territory=%(territory)s")
+ conditions+=" and territory=%(territory)s "
if filters.get("status"):
- conditions.append("status=%(status)s")
+ conditions+=" and status=%(status)s "
- return " and {}".format(" and ".join(conditions)) if conditions else ""
+ return conditions
diff --git a/erpnext/crm/report/lost_opportunity/lost_opportunity.py b/erpnext/crm/report/lost_opportunity/lost_opportunity.py
index 75c0b2d..094fa96 100644
--- a/erpnext/crm/report/lost_opportunity/lost_opportunity.py
+++ b/erpnext/crm/report/lost_opportunity/lost_opportunity.py
@@ -50,6 +50,12 @@
"fieldtype": "Link",
"options": "User",
"width": 120
+ },
+ {
+ "label": _("Lost Reasons"),
+ "fieldname": "lost_reason",
+ "fieldtype": "Data",
+ "width": 220
}
]
return columns
@@ -62,14 +68,20 @@
`tabOpportunity`.party_name,
`tabOpportunity`.customer_name,
`tabOpportunity`.opportunity_type,
- `tabOpportunity`.contact_by
+ `tabOpportunity`.contact_by,
+ GROUP_CONCAT(`tabLost Reason Detail`.lost_reason separator ', ') lost_reason
FROM
`tabOpportunity`
+ LEFT JOIN `tabLost Reason Detail`
+ ON `tabLost Reason Detail`.parenttype = 'Opportunity' and `tabLost Reason Detail`.parent = `tabOpportunity`.name
WHERE
- status = 'Lost' and company = %(company)s
+ `tabOpportunity`.status = 'Lost' and `tabOpportunity`.company = %(company)s
{conditions}
+ GROUP BY
+ `tabOpportunity`.name
ORDER BY
- creation asc """.format(conditions=get_conditions(filters)), filters, as_dict=1)
+ `tabOpportunity`.creation asc """.format(conditions=get_conditions(filters)), filters, as_dict=1)
+
def get_conditions(filters) :
conditions = []