fix: Opportunity Status fix

This commit is contained in:
Anupam K 2020-08-06 23:58:56 +05:30
parent 7fd339bbd6
commit 9d82953242
2 changed files with 8 additions and 10 deletions

View File

@ -25,7 +25,6 @@ class Quotation(SellingController):
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 @@ class Quotation(SellingController):
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 @@ class Quotation(SellingController):
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 @@ class Quotation(SellingController):
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 @@ class Quotation(SellingController):
#update enquiry status
self.set_status(update=True)
self.update_opportunity()
self.update_opportunity('Open')
self.update_lead()
def print_other_charges(self,docname):

View File

@ -159,7 +159,6 @@ class SalesOrder(SellingController):
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'):