From cdbb51537905d16de7929725e6cc8e50bc0845a5 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 16 Apr 2024 18:06:42 +0530 Subject: [PATCH 1/4] fix: address filter and quotation to for prospect (cherry picked from commit fe5b88522e8fdc11f64ff0136e41a9c1e18838d1) --- erpnext/accounts/party.py | 2 +- erpnext/selling/doctype/quotation/quotation.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 70cd8ce1f97..bd6d6b6bfe0 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -188,7 +188,7 @@ def set_address_details( *, ignore_permissions=False, ): - billing_address_field = "customer_address" if party_type == "Lead" else party_type.lower() + "_address" + billing_address_field = "customer_address" if party_type in ["Lead", "Prospect"] else party_type.lower() + "_address" party_details[billing_address_field] = party_address or get_default_address(party_type, party.name) if doctype: party_details.update( diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 95cbfd0f32b..9d13235370b 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -71,6 +71,8 @@ frappe.ui.form.on("Quotation", { frm.trigger("set_label"); frm.trigger("toggle_reqd_lead_customer"); frm.trigger("set_dynamic_field_label"); + frm.set_value("party_name", '') + frm.set_value("customer_name", '') }, set_label: function (frm) { @@ -94,10 +96,18 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. } refresh(doc, dt, dn) { super.refresh(doc, dt, dn); + let doctype = ""; + if (doc.quotation_to == "Customer") { + doctype = "Customer"; + } else if (doc.quotation_to == "Lead") { + doctype = "Lead"; + } else if (doc.quotation_to == "Prospect") { + doctype = "Prospect"; + } frappe.dynamic_link = { doc: this.frm.doc, fieldname: "party_name", - doctype: doc.quotation_to == "Customer" ? "Customer" : "Lead", + doctype: doctype, }; var me = this; @@ -197,6 +207,7 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. }; } else if (this.frm.doc.quotation_to == "Prospect") { this.frm.set_df_property("party_name", "label", "Prospect"); + this.frm.fields_dict.party_name.get_query = null; } } From 394b1f499d1aa6ee78045ef0f87b460005f4b0c2 Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 16 Apr 2024 18:12:20 +0530 Subject: [PATCH 2/4] fix: address filter and quotation to for prospect (cherry picked from commit 24a68a79dfb284843677f46a9e1f768eead5fcd5) --- erpnext/accounts/party.py | 4 +++- erpnext/selling/doctype/quotation/quotation.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index bd6d6b6bfe0..e6015e081d6 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -188,7 +188,9 @@ def set_address_details( *, ignore_permissions=False, ): - billing_address_field = "customer_address" if party_type in ["Lead", "Prospect"] else party_type.lower() + "_address" + billing_address_field = ( + "customer_address" if party_type in ["Lead", "Prospect"] else party_type.lower() + "_address" + ) party_details[billing_address_field] = party_address or get_default_address(party_type, party.name) if doctype: party_details.update( diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 9d13235370b..2073c9929c6 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -71,8 +71,8 @@ frappe.ui.form.on("Quotation", { frm.trigger("set_label"); frm.trigger("toggle_reqd_lead_customer"); frm.trigger("set_dynamic_field_label"); - frm.set_value("party_name", '') - frm.set_value("customer_name", '') + frm.set_value("party_name", "") + frm.set_value("customer_name", "") }, set_label: function (frm) { From 37741b5b45a83525cdcef51ef7566fcb5098a1ce Mon Sep 17 00:00:00 2001 From: Nihantra Patel Date: Tue, 16 Apr 2024 18:13:49 +0530 Subject: [PATCH 3/4] fix: address filter and quotation to for prospect (cherry picked from commit 2896e3666c4f034912e3d0046c0036a6f0512a73) --- erpnext/selling/doctype/quotation/quotation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 2073c9929c6..fae2723b238 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -71,8 +71,8 @@ frappe.ui.form.on("Quotation", { frm.trigger("set_label"); frm.trigger("toggle_reqd_lead_customer"); frm.trigger("set_dynamic_field_label"); - frm.set_value("party_name", "") - frm.set_value("customer_name", "") + frm.set_value("party_name", ""); + frm.set_value("customer_name", ""); }, set_label: function (frm) { From f337af9e9046f4804a8d8b9fced11e997c763238 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 9 May 2024 11:58:33 +0530 Subject: [PATCH 4/4] refactor: make use of doc.quotation_to (cherry picked from commit 754c7f6d1ca0e20d5673dea79b15097e5c66ea3b) --- erpnext/selling/doctype/quotation/quotation.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index fae2723b238..3044d865c0c 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -96,18 +96,10 @@ erpnext.selling.QuotationController = class QuotationController extends erpnext. } refresh(doc, dt, dn) { super.refresh(doc, dt, dn); - let doctype = ""; - if (doc.quotation_to == "Customer") { - doctype = "Customer"; - } else if (doc.quotation_to == "Lead") { - doctype = "Lead"; - } else if (doc.quotation_to == "Prospect") { - doctype = "Prospect"; - } frappe.dynamic_link = { doc: this.frm.doc, fieldname: "party_name", - doctype: doctype, + doctype: doc.quotation_to, }; var me = this;