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 880ddf0b9a..a57d15039e 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:59:15", "modified_by": "Administrator", "owner": "Administrator" }, @@ -83,7 +83,7 @@ "no_copy": 1, "oldfieldname": "label", "oldfieldtype": "Data", - "reqd": 1, + "reqd": 0, "search_index": 0 }, { @@ -246,6 +246,15 @@ "oldfieldtype": "Check", "search_index": 0 }, + { + "doctype": "DocField", + "fieldname": "print_width", + "fieldtype": "Data", + "hidden": 1, + "label": "Print Width", + "no_copy": 1, + "print_hide": 1 + }, { "doctype": "DocField", "fieldname": "report_hide", @@ -277,6 +286,24 @@ "oldfieldtype": "Int", "search_index": 0 }, + { + "doctype": "DocField", + "fieldname": "depends_on", + "fieldtype": "Data", + "hidden": 0, + "label": "Depends On", + "no_copy": 1, + "print_hide": 1 + }, + { + "doctype": "DocField", + "fieldname": "search_index", + "fieldtype": "Check", + "hidden": 1, + "label": "Index", + "no_copy": 1, + "print_hide": 1 + }, { "doctype": "DocPerm", "role": "Administrator"