diff --git a/erpnext/crm/report/lead_details/lead_details.py b/erpnext/crm/report/lead_details/lead_details.py index 079f32e040..9f4ae60679 100644 --- a/erpnext/crm/report/lead_details/lead_details.py +++ b/erpnext/crm/report/lead_details/lead_details.py @@ -68,12 +68,6 @@ def get_columns(): "fieldtype": "Data", "width": 120 }, - { - "label": _("Notes"), - "fieldname": "notes", - "fieldtype": "Data", - "width": 120 - }, { "label": _("Owner"), "fieldname": "owner", @@ -129,7 +123,6 @@ def get_data(filters): `tabLead`.email_id, `tabLead`.mobile_no, `tabLead`.phone, - `tabLead`.notes, `tabLead`.owner, `tabLead`.company, concat_ws(', ', @@ -153,12 +146,12 @@ def get_data(filters): `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 75c0b2d981..094fa961f7 100644 --- a/erpnext/crm/report/lost_opportunity/lost_opportunity.py +++ b/erpnext/crm/report/lost_opportunity/lost_opportunity.py @@ -50,6 +50,12 @@ def get_columns(): "fieldtype": "Link", "options": "User", "width": 120 + }, + { + "label": _("Lost Reasons"), + "fieldname": "lost_reason", + "fieldtype": "Data", + "width": 220 } ] return columns @@ -62,14 +68,20 @@ def get_data(filters): `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 = []