fix: added form script doctype to store custom script for Lead Page
This commit is contained in:
parent
0bec38a321
commit
dde6b45201
0
crm/fcrm/doctype/crm_form_script/__init__.py
Normal file
0
crm/fcrm/doctype/crm_form_script/__init__.py
Normal file
8
crm/fcrm/doctype/crm_form_script/crm_form_script.js
Normal file
8
crm/fcrm/doctype/crm_form_script/crm_form_script.js
Normal file
@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("CRM Form Script", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
70
crm/fcrm/doctype/crm_form_script/crm_form_script.json
Normal file
70
crm/fcrm/doctype/crm_form_script/crm_form_script.json
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "prompt",
|
||||
"creation": "2023-12-28 14:18:09.329868",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"dt",
|
||||
"column_break_gboh",
|
||||
"enabled",
|
||||
"section_break_xeox",
|
||||
"script"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "column_break_gboh",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_xeox",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "dt",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "DocType",
|
||||
"options": "DocType",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"fieldname": "script",
|
||||
"fieldtype": "Code",
|
||||
"label": "Script",
|
||||
"options": "JS"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-12-28 16:26:39.967069",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Form Script",
|
||||
"naming_rule": "Set by user",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
28
crm/fcrm/doctype/crm_form_script/crm_form_script.py
Normal file
28
crm/fcrm/doctype/crm_form_script/crm_form_script.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
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,
|
||||
"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,
|
||||
)
|
||||
9
crm/fcrm/doctype/crm_form_script/test_crm_form_script.py
Normal file
9
crm/fcrm/doctype/crm_form_script/test_crm_form_script.py
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
|
||||
|
||||
class TestCRMFormScript(FrappeTestCase):
|
||||
pass
|
||||
Loading…
x
Reference in New Issue
Block a user