fix: set/apply sla only if sla is enabled

This commit is contained in:
Shariq Ansari 2023-12-11 17:53:13 +05:30
parent 346310a878
commit 512783e7af
2 changed files with 16 additions and 10 deletions

View File

@ -55,7 +55,7 @@ class CRMDeal(Document):
"""
Find an SLA to apply to the deal.
"""
if sla := get_sla("CRM Deal"):
sla = get_sla("CRM Deal")
if not sla:
return
self.sla = sla.name
@ -64,7 +64,10 @@ class CRMDeal(Document):
"""
Apply SLA if set.
"""
if sla := frappe.get_last_doc("CRM Service Level Agreement", {"name": self.sla}):
if not self.sla:
return
sla = frappe.get_last_doc("CRM Service Level Agreement", {"name": self.sla})
if sla:
sla.apply(self)
@staticmethod

View File

@ -131,7 +131,7 @@ class CRMLead(Document):
"""
Find an SLA to apply to the lead.
"""
if sla := get_sla("CRM Lead"):
sla = get_sla("CRM Lead")
if not sla:
return
self.sla = sla.name
@ -140,7 +140,10 @@ class CRMLead(Document):
"""
Apply SLA if set.
"""
if sla := frappe.get_last_doc("CRM Service Level Agreement", {"name": self.sla}):
if not self.sla:
return
sla = frappe.get_last_doc("CRM Service Level Agreement", {"name": self.sla})
if sla:
sla.apply(self)
@staticmethod