From 512783e7afea766e3e59c326feaab5e506917932 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 11 Dec 2023 17:53:13 +0530 Subject: [PATCH] fix: set/apply sla only if sla is enabled --- crm/fcrm/doctype/crm_deal/crm_deal.py | 13 ++++++++----- crm/fcrm/doctype/crm_lead/crm_lead.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) 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