Merge pull request #514 from anandpdoshi/deprecate-link-selects

Deprecate link selects
This commit is contained in:
Rushabh Mehta 2014-05-09 14:08:35 +05:30
commit 1a94ae61de
19 changed files with 205 additions and 223 deletions

View file

@ -48,7 +48,7 @@ cur_frm.fields_dict['dt'].get_query = function(doc, dt, dn) {
cur_frm.cscript.fieldtype = function(doc, dt, dn) {
if(doc.fieldtype == 'Link') cur_frm.fields_dict['options_help'].disp_area.innerHTML = 'Please enter name of the document you want this field to be linked to in <b>Options</b>.<br> Eg.: Customer';
else if(doc.fieldtype == 'Select') cur_frm.fields_dict['options_help'].disp_area.innerHTML = 'Please enter values in <b>Options</b> separated by enter. <br>Eg.: <b>Field:</b> Country <br><b>Options:</b><br>China<br>India<br>United States<br><br><b> OR </b><br>You can also link it to existing Documents.<br>Eg.: <b>link:</b>Customer';
else if(doc.fieldtype == 'Select') cur_frm.fields_dict['options_help'].disp_area.innerHTML = 'Please enter values in <b>Options</b>, with each option on a new line. <br>Eg.: <b>Field:</b> Country <br><b>Options:</b><br>China<br>India<br>United States<br><br><b>';
else cur_frm.fields_dict['options_help'].disp_area.innerHTML = '';
}

View file

@ -31,7 +31,6 @@ class DocType(Document):
validate_permissions(self)
self.make_amendable()
self.check_link_replacement_error()
def change_modified_of_parent(self):
if frappe.flags.in_import:
@ -94,12 +93,6 @@ class DocType(Document):
module.on_doctype_update()
frappe.clear_cache(doctype=self.name)
def check_link_replacement_error(self):
for d in self.get("fields", {"fieldtype":"Select"}):
if (frappe.db.get_value("DocField", d.name, "options") or "").startswith("link:") \
and not d.options.startswith("link:"):
frappe.throw(_("'link:' type Select {0} getting replaced").format(d.label))
def on_trash(self):
frappe.db.sql("delete from `tabCustom Field` where dt = %s", self.name)
frappe.db.sql("delete from `tabCustom Script` where dt = %s", self.name)

View file

@ -1,17 +1,17 @@
{
"autoname": "EVP.#####",
"creation": "2013-02-22 01:27:33.000000",
"creation": "2013-02-22 01:27:33",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"fieldname": "person",
"fieldtype": "Select",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Person",
"oldfieldname": "person",
"oldfieldtype": "Select",
"options": "link:User",
"options": "User",
"permlevel": 0,
"print_width": "240px",
"search_index": 1,
@ -20,9 +20,12 @@
],
"idx": 1,
"istable": 1,
"modified": "2013-12-20 19:23:14.000000",
"modified": "2014-05-09 02:12:32.374008",
"modified_by": "Administrator",
"module": "Core",
"name": "Event User",
"owner": "Administrator"
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

View file

@ -3,21 +3,22 @@
"allow_copy": 0,
"allow_rename": 0,
"autoname": "Prompt",
"creation": "2013-01-23 19:54:43.000000",
"creation": "2013-01-23 19:54:43",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"allow_on_submit": 0,
"fieldname": "module",
"fieldtype": "Select",
"fieldtype": "Link",
"hidden": 0,
"in_filter": 1,
"in_list_view": 1,
"label": "Module",
"no_copy": 0,
"oldfieldname": "module",
"oldfieldtype": "Select",
"options": "link:Module Def",
"options": "Module Def",
"permlevel": 0,
"print_hide": 0,
"report_hide": 0,
@ -27,10 +28,11 @@
{
"description": "Belongs to",
"fieldname": "doc_type",
"fieldtype": "Select",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"label": "DocType",
"options": "link:DocType",
"options": "DocType",
"permlevel": 0,
"reqd": 0,
"search_index": 0
@ -47,6 +49,7 @@
"fieldtype": "Select",
"hidden": 0,
"in_filter": 1,
"in_list_view": 1,
"label": "Standard",
"no_copy": 1,
"oldfieldname": "standard",
@ -62,6 +65,7 @@
{
"fieldname": "print_format_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Print Format Type",
"options": "Client\nServer",
"permlevel": 0
@ -99,7 +103,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2014-01-20 17:49:00.000000",
"modified": "2014-05-09 02:12:39.540952",
"modified_by": "Administrator",
"module": "Core",
"name": "Print Format",
@ -158,5 +162,7 @@
}
],
"read_only": 0,
"read_only_onload": 0
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC"
}

View file

@ -108,8 +108,6 @@ def get_template(doctype=None, parent_doctype=None, all_doctypes="No", with_data
if docfield.fieldtype == 'Select':
if not docfield.options:
return ''
elif docfield.options.startswith('link:'):
return 'Valid %s' % docfield.options[5:]
else:
return 'One of: %s' % ', '.join(filter(None, docfield.options.split('\n')))
elif docfield.fieldtype == 'Link':

View file

@ -259,9 +259,6 @@ class BaseDocument(object):
if not doctype:
frappe.throw(_("Options not set for link field {0}").format(df.fieldname))
elif doctype.lower().startswith("link:"):
doctype = doctype[5:]
docname = self.get(df.fieldname)
if docname and not frappe.db.get_value(doctype, docname):
invalid_links.append((df.fieldname, docname, get_msg(df, docname)))

View file

@ -63,8 +63,7 @@ def get_new_doc(doctype, parent_doc = None, parentfield = None):
elif d.fieldtype == "Time":
doc.set(d.fieldname, nowtime())
elif (d.fieldtype == "Select" and d.options and not d.options.startswith("link:")
and d.options != "[Select]"):
elif (d.fieldtype == "Select" and d.options and d.options != "[Select]"):
doc.set(d.fieldname, d.options.split("\n")[0])
return doc

View file

@ -59,11 +59,7 @@ class Meta(Document):
raise
def get_link_fields(self):
tmp = self.get("fields", {"fieldtype":"Link", "options":["!=", "[Select]"]})
for df in self.get("fields", {"fieldtype":"Select", "options": "^link:"}):
tmp.append(frappe._dict({"fieldname":df.fieldname, "label":df.label,
"fieldtype":"Link", "options": df.options[5:]}))
return tmp
return self.get("fields", {"fieldtype": "Link", "options":["!=", "[Select]"]})
def get_table_fields(self):
if not hasattr(self, "_table_fields"):

View file

@ -11,7 +11,7 @@ from frappe.model.naming import validate_name
def rename_doc(doctype, old, new, force=False, merge=False, ignore_permissions=False):
"""
Renames a doc(dt, old) to doc(dt, new) and
updates all linked fields of type "Link" or "Select" with "link:"
updates all linked fields of type "Link"
"""
if not frappe.db.exists(doctype, old):
return
@ -138,9 +138,7 @@ def get_link_fields(doctype):
where dt.name = df.parent) as issingle
from tabDocField df
where
df.parent not like "old%%%%" and df.parent != '0' and
((df.options=%s and df.fieldtype='Link') or
(df.options='link:%s' and df.fieldtype='Select'))""" \
df.options=%s and df.fieldtype='Link'""" \
% ('%s', doctype), (doctype,), as_dict=1)
# get link fields from tabCustom Field
@ -150,9 +148,7 @@ def get_link_fields(doctype):
where dt.name = df.dt) as issingle
from `tabCustom Field` df
where
df.dt not like "old%%%%" and df.dt != '0' and
((df.options=%s and df.fieldtype='Link') or
(df.options='link:%s' and df.fieldtype='Select'))""" \
df.options=%s and df.fieldtype='Link'""" \
% ('%s', doctype), (doctype,), as_dict=1)
# add custom link fields list to link fields list
@ -167,7 +163,7 @@ def get_link_fields(doctype):
where
ps.property_type='options' and
ps.field_name is not null and
(ps.value=%s or ps.value='link:%s')""" \
ps.value=%s""" \
% ('%s', doctype), (doctype,), as_dict=1)
link_fields += property_setter_link_fields
@ -199,10 +195,8 @@ def get_select_fields(old, new):
where dt.name = df.parent) as issingle
from tabDocField df
where
df.parent not like "old%%%%" and df.parent != '0' and
df.parent != %s and df.fieldtype = 'Select' and
df.options not like "link:%%%%" and
(df.options like "%%%%%s%%%%")""" \
df.options like "%%%%%s%%%%" """ \
% ('%s', old), (new,), as_dict=1)
# get link fields from tabCustom Field
@ -212,10 +206,8 @@ def get_select_fields(old, new):
where dt.name = df.dt) as issingle
from `tabCustom Field` df
where
df.dt not like "old%%%%" and df.dt != '0' and
df.dt != %s and df.fieldtype = 'Select' and
df.options not like "link:%%%%" and
(df.options like "%%%%%s%%%%")""" \
df.options like "%%%%%s%%%%" """ \
% ('%s', old), (new,), as_dict=1)
# add custom link fields list to link fields list
@ -231,8 +223,7 @@ def get_select_fields(old, new):
ps.doc_type != %s and
ps.property_type='options' and
ps.field_name is not null and
ps.value not like "link:%%%%" and
(ps.value like "%%%%%s%%%%")""" \
ps.value like "%%%%%s%%%%" """ \
% ('%s', old), (new,), as_dict=1)
select_fields += property_setter_select_fields
@ -243,16 +234,14 @@ def update_select_field_values(old, new):
frappe.db.sql("""\
update `tabDocField` set options=replace(options, %s, %s)
where
parent != %s and parent not like "old%%%%" and
fieldtype = 'Select' and options not like "link:%%%%" and
parent != %s and fieldtype = 'Select' and
(options like "%%%%\\n%s%%%%" or options like "%%%%%s\\n%%%%")""" % \
('%s', '%s', '%s', old, old), (old, new, new))
frappe.db.sql("""\
update `tabCustom Field` set options=replace(options, %s, %s)
where
dt != %s and dt not like "old%%%%" and
fieldtype = 'Select' and options not like "link:%%%%" and
dt != %s and fieldtype = 'Select' and
(options like "%%%%\\n%s%%%%" or options like "%%%%%s\\n%%%%")""" % \
('%s', '%s', '%s', old, old), (old, new, new))
@ -260,7 +249,7 @@ def update_select_field_values(old, new):
update `tabProperty Setter` set value=replace(value, %s, %s)
where
doc_type != %s and field_name is not null and
property='options' and value not like "link%%%%" and
property='options' and
(value like "%%%%\\n%s%%%%" or value like "%%%%%s\\n%%%%")""" % \
('%s', '%s', '%s', old, old), (old, new, new))

View file

@ -26,3 +26,4 @@ frappe.patches.4_0.update_datetime
frappe.patches.4_0.deprecate_control_panel
frappe.patches.4_0.file_manager_hooks
execute:frappe.get_doc("User", "Guest").save()
frappe.patches.4_0.deprecate_link_selects

View file

@ -0,0 +1,13 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for name in frappe.db.sql_list("""select name from `tabCustom Field`
where fieldtype="Select" and options like "link:%" """):
custom_field = frappe.get_doc("Custom Field", name)
custom_field.fieldtype = "Link"
custom_field.options = custom_field.options[5:]
custom_field.save()

View file

@ -888,17 +888,13 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({
}
}
}).data('ui-autocomplete')._renderItem = function(ul, d) {
var html = "";
if(keys(d).length > 1) {
d.info = $.map(d, function(val, key) { return ["value", "label"].indexOf(key)!==-1 ? null : val }).join(", ") || "";
html = repl("<a>%(value)s<br><span class='text-muted'>%(info)s</span></a>", d);
} else {
html = "<a>" + d.value + "</a>";
var html = "<strong>" + d.value + "</strong>";
if(d.value!==d.description) {
html += '<br><span class="small">' + d.description + '</span>';
}
return $('<li></li>')
.data('item.autocomplete', d)
.append(html)
.html('<a><p>' + html + '</p></a>')
.appendTo(ul);
};
// remove accessibility span (for now)

View file

@ -66,7 +66,7 @@ $.extend(frappe.model, {
doc[f.fieldname] = v;
updated.push(f.fieldname);
} else if(f.fieldtype == "Select" && f.options
&& f.options.substr(0, 5)!="link:" && f.options!="[Select]") {
&& f.options!="[Select]") {
doc[f.fieldname] = f.options.split("\n")[0];
}
}

View file

@ -12,56 +12,56 @@
/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible {
.ui-helper-hidden-accessible {
border: 0; clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.ui-helper-reset {
margin: 0;
padding: 0;
border: 0;
outline: 0;
line-height: 1.3;
text-decoration: none;
font-size: 100%;
list-style: none;
.ui-helper-reset {
margin: 0;
padding: 0;
border: 0;
outline: 0;
line-height: 1.3;
text-decoration: none;
font-size: 100%;
list-style: none;
}
.ui-helper-clearfix:before,
.ui-helper-clearfix:after {
content: "";
display: table;
}
.ui-helper-clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
.ui-helper-clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.ui-helper-clearfix {
.ui-helper-clearfix {
/*display: inline-block; */
display:block;
min-height: 0; /* support: IE7 */
}
/* required comment for clearfix to work in Opera \*/
* html .ui-helper-clearfix {
height:1%;
* html .ui-helper-clearfix {
height:1%;
}
/* end clearfix */
.ui-helper-zfix {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
opacity: 0;
filter:Alpha(Opacity=0);
.ui-helper-zfix {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
opacity: 0;
filter:Alpha(Opacity=0);
}
.ui-front {
z-index: 100;
@ -77,11 +77,11 @@
----------------------------------*/
/* states and images */
.ui-icon {
display: block;
text-indent: -99999px;
overflow: hidden;
background-repeat: no-repeat;
.ui-icon {
display: block;
text-indent: -99999px;
overflow: hidden;
background-repeat: no-repeat;
}
@ -89,12 +89,12 @@
----------------------------------*/
/* Overlays */
.ui-widget-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
.ui-widget-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/*
@ -107,72 +107,72 @@
* http://api.jqueryui.com/resizable/
*/
.ui-resizable {
.ui-resizable {
position: relative;
}
.ui-resizable-handle {
.ui-resizable-handle {
position: absolute;
font-size: 0.1px;
z-index: 99999;
display: block;
z-index: 99999;
display: block;
}
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle {
display: none;
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle {
display: none;
}
.ui-resizable-n {
cursor: n-resize;
height: 7px;
width: 100%;
top: -5px;
left: 0;
.ui-resizable-n {
cursor: n-resize;
height: 7px;
width: 100%;
top: -5px;
left: 0;
}
.ui-resizable-s {
cursor: s-resize;
height: 7px;
width: 100%;
bottom: -5px;
left: 0;
.ui-resizable-s {
cursor: s-resize;
height: 7px;
width: 100%;
bottom: -5px;
left: 0;
}
.ui-resizable-e {
cursor: e-resize;
width: 7px;
right: -5px;
top: 0;
height: 100%;
.ui-resizable-e {
cursor: e-resize;
width: 7px;
right: -5px;
top: 0;
height: 100%;
}
.ui-resizable-w {
cursor: w-resize;
width: 7px;
left: -5px;
top: 0;
height: 100%;
.ui-resizable-w {
cursor: w-resize;
width: 7px;
left: -5px;
top: 0;
height: 100%;
}
.ui-resizable-se {
cursor: se-resize;
width: 12px;
height: 12px;
right: 1px;
bottom: 1px;
.ui-resizable-se {
cursor: se-resize;
width: 12px;
height: 12px;
right: 1px;
bottom: 1px;
}
.ui-resizable-sw {
cursor: sw-resize;
width: 9px;
height: 9px;
left: -5px;
bottom: -5px;
.ui-resizable-sw {
cursor: sw-resize;
width: 9px;
height: 9px;
left: -5px;
bottom: -5px;
}
.ui-resizable-nw {
cursor: nw-resize;
width: 9px;
height: 9px;
left: -5px;
top: -5px;
.ui-resizable-nw {
cursor: nw-resize;
width: 9px;
height: 9px;
left: -5px;
top: -5px;
}
.ui-resizable-ne {
cursor: ne-resize;
width: 9px;
height: 9px;
right: -5px;
.ui-resizable-ne {
cursor: ne-resize;
width: 9px;
height: 9px;
right: -5px;
top: -5px;
}
@ -185,10 +185,10 @@
*
* http://jqueryui.com/selectable/
*/
.ui-selectable-helper {
position: absolute;
z-index: 100;
border:1px dotted black;
.ui-selectable-helper {
position: absolute;
z-index: 100;
border:1px dotted black;
}
/*
@ -198,17 +198,18 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
*
*
*
* To view and modify this theme, visit http://jqueryui.com/themeroller/
*/
/* Component containers
----------------------------------*/
.ui-widget { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size:13px; }
/*.ui-widget { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size:13px; }*/
.ui-widget .ui-widget { font-size: 1em; }
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1em; }
.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(../frappe/js/lib/jquery/bootstrap_theme/images/ui-bg_glass_75_ffffff_1x400.png) 50% 50% repeat-x; color: #404040; }
/*.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1em; }*/
/*.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(../frappe/js/lib/jquery/bootstrap_theme/images/ui-bg_glass_75_ffffff_1x400.png) 50% 50% repeat-x; color: #404040; }*/
.ui-widget-content { border: 1px solid #aaaaaa; background-color: #ffffff; color: #404040;}
.ui-widget-content a { color: #404040; }
.ui-widget-header {
font-weight:bold;
@ -514,41 +515,41 @@
----------------------------------*/
/* Corner radius */
.ui-corner-all,
.ui-corner-top,
.ui-corner-left,
.ui-corner-tl {
-moz-border-radius-topleft: 4px;
-webkit-border-top-left-radius: 4px;
-khtml-border-top-left-radius: 4px;
border-top-left-radius: 4px;
.ui-corner-all,
.ui-corner-top,
.ui-corner-left,
.ui-corner-tl {
-moz-border-radius-topleft: 4px;
-webkit-border-top-left-radius: 4px;
-khtml-border-top-left-radius: 4px;
border-top-left-radius: 4px;
}
.ui-corner-all,
.ui-corner-top,
.ui-corner-right,
.ui-corner-tr {
-moz-border-radius-topright: 4px;
-webkit-border-top-right-radius: 4px;
-khtml-border-top-right-radius: 4px;
border-top-right-radius: 4px;
.ui-corner-all,
.ui-corner-top,
.ui-corner-right,
.ui-corner-tr {
-moz-border-radius-topright: 4px;
-webkit-border-top-right-radius: 4px;
-khtml-border-top-right-radius: 4px;
border-top-right-radius: 4px;
}
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-left,
.ui-corner-bl {
-moz-border-radius-bottomleft: 4px;
-webkit-border-bottom-left-radius: 4px;
-khtml-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-left,
.ui-corner-bl {
-moz-border-radius-bottomleft: 4px;
-webkit-border-bottom-left-radius: 4px;
-khtml-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-right-radius: 4px;
-khtml-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-right-radius: 4px;
-khtml-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
}
@ -562,11 +563,11 @@
* http://jqueryui.com/autocomplete/
*/
.ui-autocomplete {
position: absolute;
.ui-autocomplete {
position: absolute;
top: 0;
left: 0;
cursor: default;
cursor: default;
}
/*
@ -685,9 +686,9 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
.ui-menu .ui-menu-item a.ui-state-focus,
.ui-menu .ui-menu-item a.ui-state-active {
font-weight: normal;
margin: 0;
.ui-menu .ui-menu-item a.ui-state-active {
font-weight: normal;
margin: 0;
color: #ffffff;
background: #0064cd;
background-color: #0064cd;
@ -695,6 +696,11 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
border-color: #0064cd #0064cd #003f81;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
.ui-menu .ui-menu-item a p { margin: 3px 0px; }
.ui-menu .ui-menu-item a .small { color: #555555; }
.ui-menu .ui-menu-item a.ui-state-focus .small,
.ui-menu .ui-menu-item a.ui-state-active .small { color: #ffffff; }
/* Fix problem with border in ui-state-active */
.ui-menu .ui-menu-item a.ui-state-active {
padding: 1px .4em;
@ -884,4 +890,4 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
-moz-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
}
}

View file

@ -114,8 +114,6 @@ def make_test_records(doctype, verbose=0):
frappe.connect()
for options in get_dependencies(doctype):
if options.startswith("link:"):
options = options[5:]
if options == "[Select]":
continue

View file

@ -196,7 +196,6 @@ def get_messages_from_doctype(name):
messages.extend([d.label, d.description])
if d.fieldtype=='Select' and d.options \
and not d.options.startswith("link:") \
and not d.options.startswith("attach_files:"):
options = d.options.split('\n')
if not "icon" in options[0]:

View file

@ -105,11 +105,7 @@ def check_record(d):
frappe.msgprint(_("{0} is required").format(docfield.label), raise_exception=1)
if docfield.fieldtype=='Select' and val and docfield.options:
if docfield.options.startswith('link:'):
link_doctype = docfield.options.split(':')[1]
if not frappe.db.exists(link_doctype, val):
frappe.throw(_("{0} {1} must be a valid {2}").format(_(docfield.lable), val, _(link_doctype)))
elif docfield.options == "attach_files:":
if docfield.options == "attach_files:":
pass
elif val not in docfield.options.split('\n'):

View file

@ -29,7 +29,6 @@ class FormMeta(Meta):
self.load_assets()
def load_assets(self):
self.expand_selects()
self.add_search_fields()
if not self.istable:
@ -88,13 +87,6 @@ class FormMeta(Meta):
content = frappe.get_jenv().from_string(content).render()
return content
def expand_selects(self):
for df in self.get("fields", {"fieldtype": "Select"}):
if df.options and df.options.startswith("link:"):
df.link_doctype = df.options.split("\n")[0][5:]
df.options = '\n'.join([''] + [o.name for o in frappe.db.sql("""select
name from `tab%s` where docstatus<2 order by name asc""" % df.link_doctype, as_dict=1)])
def add_search_fields(self):
"""add search fields found in the doctypes indicated by link fields' options"""
for df in self.get("fields", {"fieldtype": "Link", "options":["!=", "[Select]"]}):

View file

@ -88,7 +88,7 @@ def get_std_fields_list(meta, key):
def build_for_autosuggest(res):
results = []
for r in res:
out = {"value": r[0], "description": ", ".join([cstr(d) for d in r[1:]])}
out = {"value": r[0], "description": ", ".join(list(set(cstr(d) for d in r[1:])))}
results.append(out)
return results