mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 11:09:17 +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
|
# Applies SLA to document on validate
|
||||||
flags = frappe.local.flags
|
flags = frappe.local.flags
|
||||||
|
|
||||||
if (
|
try:
|
||||||
flags.in_patch
|
if (
|
||||||
or flags.in_migrate
|
flags.in_patch
|
||||||
or flags.in_install
|
or flags.in_migrate
|
||||||
or flags.in_setup_wizard
|
or flags.in_install
|
||||||
or doc.doctype not in get_documents_with_active_service_level_agreement()
|
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
|
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):
|
def remove_sla_if_applied(doc):
|
||||||
doc.service_level_agreement = None
|
doc.service_level_agreement = None
|
||||||
|
|||||||
Reference in New Issue
Block a user