fix: added exception handling on service level agreement apply hook

This commit is contained in:
diptanilsaha
2025-10-13 15:14:52 +05:30
parent 1e2bcde0f5
commit dae93aa96f

View File

@@ -495,23 +495,26 @@ def apply(doc, method=None):
# Applies SLA to document on validate
flags = frappe.local.flags
if (
flags.in_patch
or flags.in_migrate
or flags.in_install
or flags.in_setup_wizard
or doc.doctype not in get_documents_with_active_service_level_agreement()
):
try:
if (
flags.in_patch
or flags.in_migrate
or flags.in_install
or flags.in_setup_wizard
or doc.doctype not in get_documents_with_active_service_level_agreement()
):
return
sla = get_active_service_level_agreement_for(doc)
if not sla:
remove_sla_if_applied(doc)
return
process_sla(doc, sla)
except Exception:
return
sla = get_active_service_level_agreement_for(doc)
if not sla:
remove_sla_if_applied(doc)
return
process_sla(doc, sla)
def remove_sla_if_applied(doc):
doc.service_level_agreement = None