From 5e98679f918618dd5bb31f432fc260f78c6409b9 Mon Sep 17 00:00:00 2001 From: Komal-Saraf0609 <81952590+Komal-Saraf0609@users.noreply.github.com> Date: Thu, 30 Mar 2023 08:03:55 +0530 Subject: [PATCH 1/4] fix: enabling lead even after "Opportunity" created against it (#34627) * fix: enabling lead even after "Opportunity" created against it * chore: Linting Issues --------- Co-authored-by: Komal Saraf Co-authored-by: Deepesh Garg (cherry picked from commit ad11934d39f0dca68630f4231031f8965fc74cf6) # Conflicts: # erpnext/patches.txt # erpnext/patches/v14_0/enable_all_leads.py --- erpnext/crm/doctype/opportunity/opportunity.py | 5 ----- erpnext/patches.txt | 5 +++++ erpnext/patches/v14_0/enable_all_leads.py | 8 ++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 erpnext/patches/v14_0/enable_all_leads.py diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index f4b6e910ed1..6a5fead0f82 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -33,7 +33,6 @@ class Opportunity(TransactionBase, CRMNote): def after_insert(self): if self.opportunity_from == "Lead": frappe.get_doc("Lead", self.party_name).set_status(update=True) - self.disable_lead() link_open_tasks(self.opportunity_from, self.party_name, self) link_open_events(self.opportunity_from, self.party_name, self) @@ -119,10 +118,6 @@ class Opportunity(TransactionBase, CRMNote): prospect.flags.ignore_mandatory = True prospect.save() - def disable_lead(self): - if self.opportunity_from == "Lead": - frappe.db.set_value("Lead", self.party_name, {"disabled": 1, "docstatus": 1}) - def make_new_lead_if_required(self): """Set lead against new opportunity""" if (not self.get("party_name")) and self.contact_email: diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 5803f46dea3..c5a88e33187 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -328,3 +328,8 @@ erpnext.patches.v14_0.set_pick_list_status erpnext.patches.v13_0.update_docs_link # below migration patches should always run last erpnext.patches.v14_0.migrate_gl_to_payment_ledger +<<<<<<< HEAD +======= +execute:frappe.delete_doc_if_exists("Report", "Tax Detail") +erpnext.patches.v15_0.enable_all_leads +>>>>>>> ad11934d39 (fix: enabling lead even after "Opportunity" created against it (#34627)) diff --git a/erpnext/patches/v14_0/enable_all_leads.py b/erpnext/patches/v14_0/enable_all_leads.py new file mode 100644 index 00000000000..c1f2b47b5bd --- /dev/null +++ b/erpnext/patches/v14_0/enable_all_leads.py @@ -0,0 +1,8 @@ +import frappe + + +def execute(): + lead = frappe.qb.DocType("Lead") + frappe.qb.update(lead).set(lead.disabled, 0).set(lead.docstatus, 0).where( + lead.disabled == 1 and lead.docstatus == 1 + ).run() From bc94358e98ca5dbffcf652de873fa25df657eb5b Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 30 Mar 2023 12:15:56 +0530 Subject: [PATCH 2/4] chore: resolve conflicts --- erpnext/patches.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c5a88e33187..82c8b06555b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -326,10 +326,7 @@ erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers erpnext.patches.v14_0.update_asset_value_for_manual_depr_entries erpnext.patches.v14_0.set_pick_list_status erpnext.patches.v13_0.update_docs_link -# below migration patches should always run last -erpnext.patches.v14_0.migrate_gl_to_payment_ledger -<<<<<<< HEAD -======= execute:frappe.delete_doc_if_exists("Report", "Tax Detail") erpnext.patches.v15_0.enable_all_leads ->>>>>>> ad11934d39 (fix: enabling lead even after "Opportunity" created against it (#34627)) +# below migration patches should always run last +erpnext.patches.v14_0.migrate_gl_to_payment_ledger From eb3e6ff145b73e974cf1eeb792e488ae11408697 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 May 2023 12:21:23 +0530 Subject: [PATCH 3/4] Update patches.txt --- erpnext/patches.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8cdc57752d1..f55f42ed469 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -326,7 +326,6 @@ erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers erpnext.patches.v14_0.update_asset_value_for_manual_depr_entries erpnext.patches.v14_0.set_pick_list_status erpnext.patches.v13_0.update_docs_link -execute:frappe.delete_doc_if_exists("Report", "Tax Detail") erpnext.patches.v15_0.enable_all_leads execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0) # below migration patches should always run last From d306bb080a1728adbab44f4236abadad7135a92e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 May 2023 12:42:36 +0530 Subject: [PATCH 4/4] Update patches.txt --- erpnext/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f55f42ed469..f010f1a1be6 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -326,7 +326,7 @@ erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers erpnext.patches.v14_0.update_asset_value_for_manual_depr_entries erpnext.patches.v14_0.set_pick_list_status erpnext.patches.v13_0.update_docs_link -erpnext.patches.v15_0.enable_all_leads +erpnext.patches.v14_0.enable_all_leads execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0) # below migration patches should always run last erpnext.patches.v14_0.migrate_gl_to_payment_ledger