Parcourir la source

Custom Field: Label is mandatory only if fieldname not exists

version-14
Nabin Hait il y a 11 ans
Parent
révision
747d3e3cba
3 fichiers modifiés avec 12 ajouts et 7 suppressions
  1. +2
    -1
      core/doctype/custom_field/custom_field.js
  2. +5
    -2
      core/doctype/custom_field/custom_field.py
  3. +5
    -4
      core/doctype/custom_field/custom_field.txt

+ 2
- 1
core/doctype/custom_field/custom_field.js Voir le fichier

@@ -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);
}




+ 5
- 2
core/doctype/custom_field/custom_field.py Voir le fichier

@@ -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


+ 5
- 4
core/doctype/custom_field/custom_field.txt Voir le fichier

@@ -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
},


Chargement…
Annuler
Enregistrer