mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-12 14:11:46 +00:00
Merge pull request #56296 from nabinhait/opportunity-auto-close-default-days
fix(crm): drive opportunity auto-close days from CRM Settings, not a hardcoded fallback
This commit is contained in:
@@ -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 = (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user