From 8c3b1b7d254ddd3d84f1e3e7f70c85a7a837bdae Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 28 May 2024 14:50:50 +0530 Subject: [PATCH] fix: allow adding multiple form script --- .../crm_form_script/crm_form_script.py | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) 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