diff --git a/crm/fcrm/doctype/crm_form_script/crm_form_script.py b/crm/fcrm/doctype/crm_form_script/crm_form_script.py index ff93ff4f..c45ff55a 100644 --- a/crm/fcrm/doctype/crm_form_script/crm_form_script.py +++ b/crm/fcrm/doctype/crm_form_script/crm_form_script.py @@ -6,27 +6,7 @@ from frappe.model.document import Document class CRMFormScript(Document): - def validate(self): - self.check_if_duplicate() - - def check_if_duplicate(self): - """Check if there is already a script for this doctype""" - if self.dt and self.enabled: - filters = { - "dt": self.dt, - "view": self.view, - "enabled": 1, - } - if self.name: - filters["name"] = ["!=", self.name] - - if frappe.db.exists("CRM Form Script", filters): - frappe.throw( - frappe._( - "Script already exists for this doctype and is enabled" - ), - frappe.DuplicateEntryError, - ) + pass def get_form_script(dt, view="Form"): """Returns the form script for the given doctype""" @@ -37,11 +17,10 @@ def get_form_script(dt, view="Form"): .where(FormScript.dt == dt) .where(FormScript.view == view) .where(FormScript.enabled == 1) - .limit(1) ) doc = query.run(as_dict=True) if doc: - return doc[0].script + return [d.script for d in doc] if len(doc) > 1 else doc[0].script else: return None