mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 08:05:00 +00:00
fix: added exception handling on service level agreement apply hook
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user