diff --git a/frappe/custom/doctype/custom_script/custom_script.json b/frappe/custom/doctype/custom_script/custom_script.json index 8fa816b4de..42a2bea18c 100644 --- a/frappe/custom/doctype/custom_script/custom_script.json +++ b/frappe/custom/doctype/custom_script/custom_script.json @@ -1,84 +1,84 @@ { - "autoname": "CustomScript.####", - "creation": "2013-01-10 16:34:01", - "description": "Adds a custom script (client or server) to a DocType", - "docstatus": 0, - "doctype": "DocType", + "autoname": "CustomScript.####", + "creation": "2013-01-10 16:34:01", + "description": "Adds a custom script (client or server) to a DocType", + "docstatus": 0, + "doctype": "DocType", "fields": [ { - "fieldname": "dt", - "fieldtype": "Link", - "in_list_view": 1, - "label": "DocType", - "oldfieldname": "dt", - "oldfieldtype": "Link", - "options": "DocType", + "fieldname": "dt", + "fieldtype": "Link", + "in_list_view": 1, + "label": "DocType", + "oldfieldname": "dt", + "oldfieldtype": "Link", + "options": "DocType", "permlevel": 0 - }, + }, { - "default": "Client", - "fieldname": "script_type", - "fieldtype": "Select", - "hidden": 1, - "in_list_view": 1, - "label": "Script Type", - "oldfieldname": "script_type", - "oldfieldtype": "Select", - "options": "Client", - "permlevel": 0, + "default": "Client", + "fieldname": "script_type", + "fieldtype": "Select", + "hidden": 1, + "in_list_view": 1, + "label": "Script Type", + "oldfieldname": "script_type", + "oldfieldtype": "Select", + "options": "Client", + "permlevel": 0, "read_only": 1 - }, + }, { - "fieldname": "script", - "fieldtype": "Code", - "in_list_view": 1, - "label": "Script", - "oldfieldname": "script", - "oldfieldtype": "Code", - "options": "Script", + "fieldname": "script", + "fieldtype": "Code", + "in_list_view": 1, + "label": "Script", + "oldfieldname": "script", + "oldfieldtype": "Code", + "options": "Script", "permlevel": 0 - }, + }, { - "fieldname": "sample", - "fieldtype": "HTML", - "label": "Sample", - "options": "

Custom Script Help

\n

Custom Scripts are executed only on the client-side (i.e. in Forms). Here are some examples to get you started

\n
\n// additional validation on dates\ncur_frm.cscript.custom_validate = function(doc) {\n    if (doc.from_date < get_today()) {\n        msgprint(\"You can not select past date in From Date\");\n        validated = false;\n    }\n}\n\n// make a field read-only after saving\ncur_frm.cscript.custom_refresh = function(doc) {\n    // use the __islocal value of doc, to check if the doc is saved or not\n    cur_frm.set_df_property(\"myfield\", \"read_only\", doc.__islocal ? 0 : 1);\n}\n\n// addtional permission checking\ncur_frm.cscript.custom_validate = function(doc) {\n    if(user==\"user1@example.com\" && doc.purpose!=\"Material Receipt\") {\n        msgprint(\"You are only allowed Material Receipt\");\n        validated = false;\n    }\n}\n\n// calculate sales incentive\ncur_frm.cscript.custom_validate = function(doc) {\n    // calculate incentives for each person on the deal\n    total_incentive = 0\n    $.each(wn.model.get(\"Sales Team\", {parent:doc.name}), function(i, d) {\n\n        // calculate incentive\n        var incentive_percent = 2;\n        if(doc.grand_total > 400) incentive_percent = 4;\n\n        // actual incentive\n        d.incentives = flt(doc.grand_total) * incentive_percent / 100;\n        total_incentive += flt(d.incentives)\n    });\n\n    doc.total_incentive = total_incentive;\n}\n\n
", + "fieldname": "sample", + "fieldtype": "HTML", + "label": "Sample", + "options": "

Custom Script Help

\n

Custom Scripts are executed only on the client-side (i.e. in Forms). Here are some examples to get you started

\n
\n// additional validation on dates\ncur_frm.cscript.custom_validate = function(doc) {\n    if (doc.from_date < get_today()) {\n        msgprint(\"You can not select past date in From Date\");\n        validated = false;\n    }\n}\n\n// make a field read-only after saving\ncur_frm.cscript.custom_refresh = function(doc) {\n    // use the __islocal value of doc, to check if the doc is saved or not\n    cur_frm.set_df_property(\"myfield\", \"read_only\", doc.__islocal ? 0 : 1);\n}\n\n// addtional permission checking\ncur_frm.cscript.custom_validate = function(doc) {\n    if(user==\"user1@example.com\" && doc.purpose!=\"Material Receipt\") {\n        msgprint(\"You are only allowed Material Receipt\");\n        validated = false;\n    }\n}\n\n// calculate sales incentive\ncur_frm.cscript.custom_validate = function(doc) {\n    // calculate incentives for each person on the deal\n    total_incentive = 0\n    $.each(doc.sales_team), function(i, d) {\n\n        // calculate incentive\n        var incentive_percent = 2;\n        if(doc.grand_total > 400) incentive_percent = 4;\n\n        // actual incentive\n        d.incentives = flt(doc.grand_total) * incentive_percent / 100;\n        total_incentive += flt(d.incentives)\n    });\n\n    doc.total_incentive = total_incentive;\n}\n\n
", "permlevel": 0 } - ], - "icon": "icon-glass", - "idx": 1, - "modified": "2014-06-19 06:55:02.522205", - "modified_by": "Administrator", - "module": "Custom", - "name": "Custom Script", - "owner": "Administrator", + ], + "icon": "icon-glass", + "idx": 1, + "modified": "2014-10-06 08:18:26.397814", + "modified_by": "Administrator", + "module": "Custom", + "name": "Custom Script", + "owner": "Administrator", "permissions": [ { - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "submit": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "submit": 0, "write": 1 - }, + }, { - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Administrator", - "submit": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Administrator", + "submit": 0, "write": 1 } ] -} +} \ No newline at end of file