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,16 +55,19 @@ class CRMDeal(Document):
""" """
Find an SLA to apply to the deal. Find an SLA to apply to the deal.
""" """
if sla := get_sla("CRM Deal"): sla = get_sla("CRM Deal")
if not sla: if not sla:
return return
self.sla = sla.name self.sla = sla.name
def apply_sla(self): def apply_sla(self):
""" """
Apply SLA if set. 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) sla.apply(self)
@staticmethod @staticmethod

View File

@ -131,16 +131,19 @@ class CRMLead(Document):
""" """
Find an SLA to apply to the lead. Find an SLA to apply to the lead.
""" """
if sla := get_sla("CRM Lead"): sla = get_sla("CRM Lead")
if not sla: if not sla:
return return
self.sla = sla.name self.sla = sla.name
def apply_sla(self): def apply_sla(self):
""" """
Apply SLA if set. 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) sla.apply(self)
@staticmethod @staticmethod