From d16ef54665702efd7f43ba5943b6d54553cfe6a7 Mon Sep 17 00:00:00 2001 From: Pranav Nachnekar Date: Wed, 4 Dec 2019 10:01:25 +0000 Subject: [PATCH] fix: query for finding lost quotation (#19801) * fix:query for finding lost quotation * Update opportunity.py --- erpnext/crm/doctype/opportunity/opportunity.py | 9 +++++---- erpnext/selling/doctype/quotation/quotation.py | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index 99486fa2066..4e0eebd0de9 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -130,10 +130,11 @@ class Opportunity(TransactionBase): def has_lost_quotation(self): lost_quotation = frappe.db.sql(""" - select q.name - from `tabQuotation` q, `tabQuotation Item` qi - where q.name = qi.parent and q.docstatus=1 - and qi.prevdoc_docname =%s and q.status = 'Lost' + select name + from `tabQuotation` + where docstatus=1 + and opportunity =%s + and status = 'Lost' """, self.name) if lost_quotation: if self.has_active_quotation(): diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 790b2f0804d..488331a8102 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -67,7 +67,6 @@ class Quotation(SellingController): opportunity = self.opportunity opp = frappe.get_doc("Opportunity", opportunity) - opp.status = None opp.set_status(update=True) def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None):