From 6ba48c58e8ad6b6859fbed82ff7a6f1f57584796 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 1 Apr 2019 19:08:59 +0530 Subject: [PATCH] fix: Server side handling of quotation to and get_query fix --- .../selling/doctype/quotation/quotation.js | 8 +++---- .../selling/doctype/quotation/quotation.py | 22 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 7d5118cff21..dcd20917796 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -26,6 +26,8 @@ frappe.ui.form.on('Quotation', { quotation_to: function(frm) { frm.trigger("set_label"); + frm.trigger("set_dynamic_field_label"); + frm.trigger("toggle_reqd_lead_customer"); }, set_label: function(frm) { @@ -106,15 +108,11 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ }, - quotation_to: function(frm) { - this.set_dynamic_field_label(); - this.toggle_reqd_lead_customer(); - }, - set_dynamic_field_label: function(){ if (this.frm.doc.quotation_to == "Customer") { this.frm.set_df_property("customer_lead", "label", "Customer"); + this.frm.fields_dict.customer_lead.get_query = null; } if (this.frm.doc.quotation_to == "Lead") diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 729256068be..cea2b356c0d 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -28,11 +28,11 @@ class Quotation(SellingController): self.update_opportunity() self.validate_order_type() self.validate_uom_is_integer("stock_uom", "qty") - self.validate_quotation_to() + # self.validate_quotation_to() self.validate_valid_till() if self.items: self.with_items = 1 - + def validate_valid_till(self): if self.valid_till and self.valid_till < self.transaction_date: frappe.throw(_("Valid till date cannot be before transaction date")) @@ -43,16 +43,16 @@ class Quotation(SellingController): def validate_order_type(self): super(Quotation, self).validate_order_type() - def validate_quotation_to(self): - if self.customer: - self.quotation_to = "Customer" - self.lead = None - elif self.lead: - self.quotation_to = "Lead" + # def validate_quotation_to(self): + # if self.customer: + # self.quotation_to = "Customer" + # self.lead = None + # elif self.lead: + # self.quotation_to = "Lead" def update_lead(self): - if self.lead: - frappe.get_doc("Lead", self.lead).set_status(update=True) + if self.quotation_to == "Lead": + frappe.get_doc("Lead", self.customer_lead).set_status(update=True) def update_opportunity(self): for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])): @@ -209,7 +209,7 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): } }, target_doc, set_missing_values, ignore_permissions=ignore_permissions) - return doclist + return doclist def _make_customer(source_name, ignore_permissions=False): quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type", "customer"])