Merge pull request #22944 from anupamvs/opportunity-status

fix: Opportunity Status fix
This commit is contained in:
rohitwaghchaure 2021-01-11 17:34:06 +05:30 committed by GitHub
commit c92da35997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 11 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,21 +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.set_status(update=True)
opp.set_status(status=status, update=True)
def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None):
if not self.has_sales_order():
@ -82,7 +80,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 +93,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 +103,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

@ -158,7 +158,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'):