updated import to take options from property setter
This commit is contained in:
parent
eb885efc97
commit
68b1fe780b
2 changed files with 22 additions and 2 deletions
|
|
@ -294,6 +294,24 @@ def get_property(dt, property):
|
|||
else:
|
||||
return webnotes.conn.get_value('DocType', dt, property)
|
||||
|
||||
def get_field_property(dt, fieldname, property):
|
||||
"""
|
||||
get a field property, override it from property setter if specified
|
||||
"""
|
||||
field = webnotes.conn.sql("""
|
||||
select name, `%s`
|
||||
from tabDocField
|
||||
where parent=%s and fieldname=%s""" % (property, '%s', '%s'), (dt, fieldname))
|
||||
|
||||
prop = webnotes.conn.sql("""
|
||||
select value
|
||||
from `tabProperty Setter`
|
||||
where doc_type=%s and doc_name=%s and property=%s""", (dt, field[0][0], property))
|
||||
if prop:
|
||||
return prop[0][0]
|
||||
else:
|
||||
return field[0][1]
|
||||
|
||||
def get(dt):
|
||||
"""
|
||||
Load "DocType" - called by form builder, report buider and from code.py (when there is no cache)
|
||||
|
|
|
|||
|
|
@ -197,11 +197,13 @@ class CSVImport:
|
|||
return out
|
||||
|
||||
def check_select_link_data(self, r, c, f, d, s = '', l = ''):
|
||||
from webnotes.model.doctype import get_field_property
|
||||
options = ''
|
||||
try:
|
||||
if d and f:
|
||||
dt = sql("select options, label from `tabDocField` where fieldname ='%s' and parent = '%s' " % (f, self.dt_list[0]))
|
||||
dt, lbl = (dt and dt[0][0] and dt[0][0].strip() or None), dt and dt[0][1].strip()
|
||||
dt = get_field_property(self.dt_list[0], f, 'options')
|
||||
lbl = get_field_property(self.dt_list[0], f, 'label')
|
||||
|
||||
if dt:
|
||||
options = l and dt and [n[0] for n in sql("select name from `tab%s` " % (('link:' in dt and dt[5:]) or dt))] or s and dt.split('\n') or ''
|
||||
if options and d not in options :
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue