diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index ede7271132f..84ac1f4d300 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -399,8 +399,8 @@ def set_multiple_status(names: str | list[str], status: str): def auto_close_opportunity(): - """auto close the `Replied` Opportunities after 7 days""" - auto_close_after_days = frappe.db.get_single_value("CRM Settings", "close_opportunity_after_days") or 15 + """Auto close `Replied` Opportunities inactive for the days configured in CRM Settings.""" + auto_close_after_days = frappe.db.get_single_value("CRM Settings", "close_opportunity_after_days") table = frappe.qb.DocType("Opportunity") opportunities = ( diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 5db549806a3..65687c7c118 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -489,3 +489,4 @@ erpnext.patches.v16_0.submit_existing_product_bundles #1 erpnext.patches.v16_0.migrate_subscription_generate_invoice_at erpnext.patches.v16_0.rename_subscription_billing_period_fields erpnext.patches.v16_0.drop_redundant_serial_no_index_from_sabb +erpnext.patches.v16_0.set_default_close_opportunity_after_days diff --git a/erpnext/patches/v16_0/set_default_close_opportunity_after_days.py b/erpnext/patches/v16_0/set_default_close_opportunity_after_days.py new file mode 100644 index 00000000000..736b584e1de --- /dev/null +++ b/erpnext/patches/v16_0/set_default_close_opportunity_after_days.py @@ -0,0 +1,12 @@ +import frappe + + +def execute(): + """Backfill the default for CRM Settings.close_opportunity_after_days. + + The auto-close logic used to fall back to 15 days in code. Now that the fallback is removed, + existing sites that never set the value (left blank / 0) need it filled in so opportunities + keep auto-closing on the same schedule. + """ + if not frappe.db.get_single_value("CRM Settings", "close_opportunity_after_days"): + frappe.db.set_single_value("CRM Settings", "close_opportunity_after_days", 15)