diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 87cdfb72..ac215ed5 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -55,16 +55,19 @@ class CRMDeal(Document): """ Find an SLA to apply to the deal. """ - if sla := get_sla("CRM Deal"): - if not sla: - return - self.sla = sla.name + sla = get_sla("CRM Deal") + if not sla: + return + self.sla = sla.name def apply_sla(self): """ 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 diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.py b/crm/fcrm/doctype/crm_lead/crm_lead.py index e9e20487..f8a0fb6d 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.py +++ b/crm/fcrm/doctype/crm_lead/crm_lead.py @@ -131,16 +131,19 @@ class CRMLead(Document): """ Find an SLA to apply to the lead. """ - if sla := get_sla("CRM Lead"): - if not sla: - return - self.sla = sla.name + sla = get_sla("CRM Lead") + if not sla: + return + self.sla = sla.name def apply_sla(self): """ 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