fix: Opportunity Status fix
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 449a968..01479a1 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -25,7 +25,6 @@
def validate(self):
super(Quotation, self).validate()
self.set_status()
- self.update_opportunity()
self.validate_uom_is_integer("stock_uom", "qty")
self.validate_valid_till()
self.set_customer_name()
@@ -50,20 +49,20 @@
lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"])
self.customer_name = company_name or lead_name
- def update_opportunity(self):
+ def update_opportunity(self, status):
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
if opportunity:
- self.update_opportunity_status(opportunity)
+ self.update_opportunity_status(status, opportunity)
if self.opportunity:
- self.update_opportunity_status()
+ self.update_opportunity_status(status)
- def update_opportunity_status(self, opportunity=None):
+ def update_opportunity_status(self, status, opportunity=None):
if not opportunity:
opportunity = self.opportunity
opp = frappe.get_doc("Opportunity", opportunity)
- opp.status = None
+ opp.status = status
opp.set_status(update=True)
def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None):
@@ -82,7 +81,7 @@
else:
frappe.throw(_("Invalid lost reason {0}, please create a new lost reason").format(frappe.bold(reason.get('lost_reason'))))
- self.update_opportunity()
+ self.update_opportunity('Lost')
self.update_lead()
self.save()
@@ -95,7 +94,7 @@
self.company, self.base_grand_total, self)
#update enquiry status
- self.update_opportunity()
+ self.update_opportunity('Quotation')
self.update_lead()
def on_cancel(self):
@@ -105,7 +104,7 @@
#update enquiry status
self.set_status(update=True)
- self.update_opportunity()
+ self.update_opportunity('Open')
self.update_lead()
def print_other_charges(self,docname):
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index ffb6635..f17af69 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -159,7 +159,6 @@
frappe.throw(_("Quotation {0} is cancelled").format(quotation))
doc.set_status(update=True)
- doc.update_opportunity()
def validate_drop_ship(self):
for d in self.get('items'):