Merge branch 'master' into edge

This commit is contained in:
Rushabh Mehta 2013-04-03 10:42:09 +05:30
commit aba6a77fff
5 changed files with 30 additions and 10 deletions

View file

@ -81,6 +81,7 @@ class DocType:
self.set_version()
self.make_amendable()
self.make_file_list()
self.check_link_replacement_error()
def on_update(self):
from webnotes.model.db_schema import updatedb
@ -97,6 +98,13 @@ class DocType:
webnotes.clear_cache(doctype=self.doc.name)
def check_link_replacement_error(self):
for d in self.doclist.get({"doctype":"DocField", "fieldtype":"Select"}):
if (webnotes.conn.get_value("DocField", d.name, "options") or "").startswith("link:") \
and not d.options.startswith("link:"):
webnotes.msgprint("link: type Select fields are getting replaced. Please check for %s" % d.label,
raise_exception=True)
def on_trash(self):
webnotes.conn.sql("delete from `tabCustom Field` where dt = %s", self.doc.name)
webnotes.conn.sql("delete from `tabCustom Script` where dt = %s", self.doc.name)

View file

@ -267,10 +267,8 @@ def check_record(d, parenttype=None):
if docfield.reqd and (val=='' or val==None):
raise Exception, "%s is mandatory." % key
if docfield.fieldtype=='Select' and val:
if not docfield.options:
raise Exception, "Select options are missing for %s"
elif docfield.options.startswith('link:'):
if docfield.fieldtype=='Select' and val and docfield.options:
if docfield.options.startswith('link:'):
link_doctype = docfield.options.split(':')[1]
if not webnotes.conn.exists(link_doctype, val):
raise Exception, "%s must be a valid %s" % (key, link_doctype)

View file

@ -2244,5 +2244,16 @@
"currency_fraction_units": 100,
"currency_symbol": "P",
"number_format": "#,###.##"
},
"Aruba": {
"currency_fraction": "Cent",
"timezones": [
"America/Aruba"
],
"currency_name": "Aruban Florin",
"currency": "AWG",
"currency_fraction_units": 100,
"currency_symbol": "Afl",
"number_format": "#,###.##"
}
}

View file

@ -248,8 +248,11 @@ class Session:
exp_sec = webnotes.defaults.get_global_default("session_expiry") or "06:00:00"
# incase seconds is missing
if len(exp_sec.split(':')) == 2:
exp_sec = exp_sec + ':00'
if exp_sec:
if len(exp_sec.split(':')) == 2:
exp_sec = exp_sec + ':00'
else:
exp_sec = "2:00:00"
return exp_sec

View file

@ -63,7 +63,7 @@ def execute(doctype, query=None, filters=None, fields=None, docstatus=None,
query = """select %(fields)s from %(tables)s where %(conditions)s
%(group_by)s order by %(order_by)s %(limit)s""" % args
return webnotes.conn.sql(query, as_dict=1)
return webnotes.conn.sql(query, as_dict=1, debug=1)
def prepare_args(doctype, filters, fields, docstatus, group_by, order_by):
global tables
@ -156,7 +156,7 @@ def build_conditions(doctype, fields, filters, docstatus):
# make conditions from filters
build_filter_conditions(filters, conditions)
# join parent, child tables
for tname in tables[1:]:
conditions.append(tname + '.parent = ' + tables[0] + '.name')
@ -179,12 +179,12 @@ def build_filter_conditions(filters, conditions):
# prepare in condition
if f[2]=='in':
opts = ["'" + t.strip().replace("'", "\'") + "'" for t in f[3].split(',')]
opts = ["'" + t.strip().replace("'", "\\'") + "'" for t in f[3].split(',')]
f[3] = "(" + ', '.join(opts) + ")"
conditions.append(tname + '.' + f[1] + " " + f[2] + " " + f[3])
else:
if isinstance(f[3], basestring):
f[3] = "'" + f[3].replace("'", "\'") + "'"
f[3] = "'" + f[3].replace("'", "\\'") + "'"
conditions.append(tname + '.' + f[1] + " " + f[2] + " " + f[3])
else:
conditions.append('ifnull(' + tname + '.' + f[1] + ",0) " + f[2] \