diff --git a/core/doctype/custom_field/custom_field.py b/core/doctype/custom_field/custom_field.py index 5099123d4f..d7909de560 100644 --- a/core/doctype/custom_field/custom_field.py +++ b/core/doctype/custom_field/custom_field.py @@ -9,6 +9,10 @@ from webnotes.utils import cint, cstr class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl + + def autoname(self): + self.set_fieldname() + self.doc.name = self.doc.dt + "-" + self.doc.fieldname def set_fieldname(self): if not self.doc.fieldname: @@ -104,7 +108,7 @@ def get_fields_label(dt=None, form=1): field_list = [cstr(d.fieldname) for d in docfields] return idx_label_list, field_list -def delete_and_create_custom_field_if_values_exist(doctype, df): +def create_custom_field_if_values_exist(doctype, df): df = webnotes._dict(df) if webnotes.conn.sql("""select count(*) from `tab{doctype}` where ifnull({fieldname},'')!=''""".format(doctype=doctype, fieldname=df.fieldname))[0][0]: diff --git a/core/doctype/custom_field/custom_field.txt b/core/doctype/custom_field/custom_field.txt index 7600c7868e..e0831523dd 100644 --- a/core/doctype/custom_field/custom_field.txt +++ b/core/doctype/custom_field/custom_field.txt @@ -2,12 +2,11 @@ { "creation": "2013-01-10 16:34:01", "docstatus": 0, - "modified": "2013-07-05 14:33:59", + "modified": "2013-11-05 20:07:27", "modified_by": "Administrator", "owner": "Administrator" }, { - "autoname": "eval:doc.dt+\"-\"+doc.fieldname", "description": "Adds a custom field to a DocType", "doctype": "DocType", "icon": "icon-glass", diff --git a/core/doctype/doctype/doctype.txt b/core/doctype/doctype/doctype.txt index 4063f13254..36628e253c 100644 --- a/core/doctype/doctype/doctype.txt +++ b/core/doctype/doctype/doctype.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-18 13:36:19", "docstatus": 0, - "modified": "2013-11-02 23:01:10", + "modified": "2013-11-05 20:09:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -155,7 +155,7 @@ "fieldtype": "Section Break" }, { - "description": "\\\n
  • field:[fieldname] - By Field\\\n
  • naming_series: - By Naming Series (field called naming_series must be present\\\n
  • eval:[expression] - Evaluate an expression in python (self is doc)\\\n
  • Prompt - Prompt user for a name\\\n
  • [series] - Series by prefix (separated by a dot); for example PRE.#####\\\n')\">Naming Options", + "description": "\\\n
  • field:[fieldname] - By Field\\\n
  • naming_series: - By Naming Series (field called naming_series must be present\\\n
  • Prompt - Prompt user for a name\\\n
  • [series] - Series by prefix (separated by a dot); for example PRE.#####\\\n')\">Naming Options", "doctype": "DocField", "fieldname": "autoname", "fieldtype": "Data", diff --git a/public/js/legacy/clientscriptAPI.js b/public/js/legacy/clientscriptAPI.js index 9a102da5c2..77280bc39e 100644 --- a/public/js/legacy/clientscriptAPI.js +++ b/public/js/legacy/clientscriptAPI.js @@ -133,12 +133,12 @@ _f.Frm.prototype.field_map = function(fnames, fn) { fnames = [fnames]; } } - $.each(fnames, function(i,f) { + $.each(fnames, function(i,fieldname) { //var field = cur_frm.fields_dict[f]; - much better design - var field = wn.meta.get_docfield(cur_frm.doctype, f, cur_frm.docname) + var field = wn.meta.get_docfield(cur_frm.doctype, fieldname, cur_frm.docname); if(field) { fn(field); - cur_frm.refresh_field(f); + cur_frm.refresh_field(fieldname); }; }) diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index 2de1c2cbcc..1ba8d412e9 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -147,8 +147,8 @@ wn.ui.form.ControlInput = wn.ui.form.Control.extend({ } else { this.$wrapper = $('
    \
    \ - \ -
    \ + \ +
    \
    \ \

    \ @@ -450,13 +450,13 @@ wn.ui.form.ControlCheck = wn.ui.form.ControlData.extend({ input_type: "checkbox", make_wrapper: function() { this.$wrapper = $('
    \ -
    \ -
    \ +
    \ +
    \ \ -

     

    \ +

    \
    \
    \
    ').appendTo(this.parent) @@ -697,9 +697,10 @@ wn.ui.form.ControlSelect = wn.ui.form.ControlData.extend({ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({ make_input: function() { var me = this; - $('