fix: do not allow to create multiple default SLA for same doctype
This commit is contained in:
parent
59a508b88a
commit
cb0e3e3171
@ -18,8 +18,23 @@ from crm.fcrm.doctype.crm_service_level_agreement.utils import get_context
|
|||||||
|
|
||||||
class CRMServiceLevelAgreement(Document):
|
class CRMServiceLevelAgreement(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_default()
|
||||||
self.validate_condition()
|
self.validate_condition()
|
||||||
|
|
||||||
|
def validate_default(self):
|
||||||
|
if self.default:
|
||||||
|
other_slas = frappe.get_all(
|
||||||
|
"CRM Service Level Agreement",
|
||||||
|
filters={"apply_on": self.apply_on, "default": True},
|
||||||
|
fields=["name"],
|
||||||
|
)
|
||||||
|
if other_slas:
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Default Service Level Agreement already exists for {0}"
|
||||||
|
).format(self.apply_on)
|
||||||
|
)
|
||||||
|
|
||||||
def validate_condition(self):
|
def validate_condition(self):
|
||||||
if not self.condition:
|
if not self.condition:
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user