Merge pull request #22944 from anupamvs/opportunity-status
fix: Opportunity Status fix
This commit is contained in:
commit
c92da35997
@ -25,7 +25,6 @@ class Quotation(SellingController):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
super(Quotation, self).validate()
|
super(Quotation, self).validate()
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.update_opportunity()
|
|
||||||
self.validate_uom_is_integer("stock_uom", "qty")
|
self.validate_uom_is_integer("stock_uom", "qty")
|
||||||
self.validate_valid_till()
|
self.validate_valid_till()
|
||||||
self.set_customer_name()
|
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"])
|
lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"])
|
||||||
self.customer_name = company_name or lead_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")])):
|
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
|
||||||
if opportunity:
|
if opportunity:
|
||||||
self.update_opportunity_status(opportunity)
|
self.update_opportunity_status(status, opportunity)
|
||||||
|
|
||||||
if self.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:
|
if not opportunity:
|
||||||
opportunity = self.opportunity
|
opportunity = self.opportunity
|
||||||
|
|
||||||
opp = frappe.get_doc("Opportunity", opportunity)
|
opp = frappe.get_doc("Opportunity", opportunity)
|
||||||
opp.status = None
|
opp.set_status(status=status, update=True)
|
||||||
opp.set_status(update=True)
|
|
||||||
|
|
||||||
def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None):
|
def declare_enquiry_lost(self, lost_reasons_list, detailed_reason=None):
|
||||||
if not self.has_sales_order():
|
if not self.has_sales_order():
|
||||||
@ -82,7 +80,7 @@ class Quotation(SellingController):
|
|||||||
else:
|
else:
|
||||||
frappe.throw(_("Invalid lost reason {0}, please create a new lost reason").format(frappe.bold(reason.get('lost_reason'))))
|
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.update_lead()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
@ -95,7 +93,7 @@ class Quotation(SellingController):
|
|||||||
self.company, self.base_grand_total, self)
|
self.company, self.base_grand_total, self)
|
||||||
|
|
||||||
#update enquiry status
|
#update enquiry status
|
||||||
self.update_opportunity()
|
self.update_opportunity('Quotation')
|
||||||
self.update_lead()
|
self.update_lead()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
@ -105,7 +103,7 @@ class Quotation(SellingController):
|
|||||||
|
|
||||||
#update enquiry status
|
#update enquiry status
|
||||||
self.set_status(update=True)
|
self.set_status(update=True)
|
||||||
self.update_opportunity()
|
self.update_opportunity('Open')
|
||||||
self.update_lead()
|
self.update_lead()
|
||||||
|
|
||||||
def print_other_charges(self,docname):
|
def print_other_charges(self,docname):
|
||||||
|
@ -158,7 +158,6 @@ class SalesOrder(SellingController):
|
|||||||
frappe.throw(_("Quotation {0} is cancelled").format(quotation))
|
frappe.throw(_("Quotation {0} is cancelled").format(quotation))
|
||||||
|
|
||||||
doc.set_status(update=True)
|
doc.set_status(update=True)
|
||||||
doc.update_opportunity()
|
|
||||||
|
|
||||||
def validate_drop_ship(self):
|
def validate_drop_ship(self):
|
||||||
for d in self.get('items'):
|
for d in self.get('items'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user