diff --git a/core/doctype/custom_field/custom_field.js b/core/doctype/custom_field/custom_field.js index 0407ff8f5e..e099f699f0 100644 --- a/core/doctype/custom_field/custom_field.js +++ b/core/doctype/custom_field/custom_field.js @@ -6,8 +6,9 @@ // -------- cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.toggle_enable('dt', doc.__islocal) + cur_frm.toggle_enable('dt', doc.__islocal); cur_frm.cscript.dt(doc, cdt, cdn); + cur_frm.toggle_reqd('label', !doc.fieldname); } diff --git a/core/doctype/custom_field/custom_field.py b/core/doctype/custom_field/custom_field.py index 3c6753462d..a9174381aa 100644 --- a/core/doctype/custom_field/custom_field.py +++ b/core/doctype/custom_field/custom_field.py @@ -3,8 +3,8 @@ from __future__ import unicode_literals import webnotes - from webnotes.utils import cint, cstr +from webnotes import _ class DocType: def __init__(self, d, dl): @@ -16,8 +16,11 @@ class DocType: def set_fieldname(self): if not self.doc.fieldname: + if not self.doc.label: + webnotes.throw(_("Label is mandatory")) # remove special characters from fieldname - self.doc.fieldname = filter(lambda x: x.isdigit() or x.isalpha() or '_', cstr(self.doc.label).lower().replace(' ','_')) + self.doc.fieldname = filter(lambda x: x.isdigit() or x.isalpha() or '_', + cstr(self.doc.label).lower().replace(' ','_')) def validate(self): from webnotes.model.doctype import get diff --git a/core/doctype/custom_field/custom_field.txt b/core/doctype/custom_field/custom_field.txt index 7a18e669b3..cb5cbfd467 100644 --- a/core/doctype/custom_field/custom_field.txt +++ b/core/doctype/custom_field/custom_field.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:01", "docstatus": 0, - "modified": "2014-01-10 15:04:04", + "modified": "2014-01-13 17:46:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -29,7 +29,6 @@ "parentfield": "permissions", "parenttype": "DocType", "read": 1, - "report": 1, "submit": 0 }, { @@ -79,7 +78,7 @@ "no_copy": 1, "oldfieldname": "label", "oldfieldtype": "Data", - "reqd": 1, + "reqd": 0, "search_index": 0 }, { @@ -286,7 +285,7 @@ "doctype": "DocField", "fieldname": "depends_on", "fieldtype": "Data", - "hidden": 1, + "hidden": 0, "label": "Depends On", "no_copy": 1, "print_hide": 1 @@ -305,6 +304,7 @@ "create": 1, "doctype": "DocPerm", "permlevel": 0, + "report": 1, "role": "Administrator", "write": 1 }, @@ -329,6 +329,7 @@ "create": 1, "doctype": "DocPerm", "permlevel": 0, + "report": 1, "role": "System Manager", "write": 1 },