@@ -273,11 +273,10 @@ def validate_fields(meta): | |||||
if fold_exists: | if fold_exists: | ||||
frappe.throw(_("There can be only one Fold in a form")) | frappe.throw(_("There can be only one Fold in a form")) | ||||
fold_exists = True | fold_exists = True | ||||
if i < len(fields)-2: | |||||
if i < len(fields)-1: | |||||
nxt = fields[i+1] | nxt = fields[i+1] | ||||
if nxt.fieldtype != "Section Break" \ | |||||
or (nxt.fieldtype=="Section Break" and not nxt.label): | |||||
frappe.throw(_("Fold must come before a labelled Section Break")) | |||||
if nxt.fieldtype != "Section Break": | |||||
frappe.throw(_("Fold must come before a Section Break")) | |||||
else: | else: | ||||
frappe.throw(_("Fold can not be at the end of the form")) | frappe.throw(_("Fold can not be at the end of the form")) | ||||
@@ -680,6 +680,10 @@ class Database: | |||||
"""Returns list of column names from given doctype.""" | """Returns list of column names from given doctype.""" | ||||
return [r[0] for r in self.sql("DESC `tab%s`" % doctype)] | return [r[0] for r in self.sql("DESC `tab%s`" % doctype)] | ||||
def has_column(self, doctype, column): | |||||
"""Returns True if column exists in database.""" | |||||
return column in self.get_table_columns(doctype) | |||||
def add_index(self, doctype, fields, index_name=None): | def add_index(self, doctype, fields, index_name=None): | ||||
"""Creates an index with given fields if not already created. | """Creates an index with given fields if not already created. | ||||
Index name will be `fieldname1_fieldname2_index`""" | Index name will be `fieldname1_fieldname2_index`""" | ||||
@@ -13,11 +13,8 @@ from frappe import _ | |||||
def get(): | def get(): | ||||
return compress(execute(**get_form_params())) | return compress(execute(**get_form_params())) | ||||
def execute(doctype, query=None, filters=None, fields=None, or_filters=None, docstatus=None, | |||||
group_by=None, order_by=None, limit_start=0, limit_page_length=20, | |||||
as_list=False, with_childnames=False, debug=False, ignore_permissions=False): | |||||
return DatabaseQuery(doctype).execute(query, filters, fields, or_filters, docstatus, group_by, | |||||
order_by, limit_start, limit_page_length, as_list, with_childnames, debug, ignore_permissions) | |||||
def execute(doctype, *args, **kwargs): | |||||
return DatabaseQuery(doctype).execute(*args, **kwargs) | |||||
def get_form_params(): | def get_form_params(): | ||||
"""Stringify GET request parameters.""" | """Stringify GET request parameters.""" | ||||
@@ -48,7 +48,7 @@ class EmailAccount(Document): | |||||
for fn in ("default_incoming", "default_outgoing"): | for fn in ("default_incoming", "default_outgoing"): | ||||
if self.get(fn): | if self.get(fn): | ||||
for email_account in frappe.get_all("Email Account", | for email_account in frappe.get_all("Email Account", | ||||
{fn: 1}): | |||||
filters={fn: 1}): | |||||
if email_account.name==self.name: | if email_account.name==self.name: | ||||
continue | continue | ||||
email_account = frappe.get_doc("Email Account", | email_account = frappe.get_doc("Email Account", | ||||
@@ -21,7 +21,7 @@ class DatabaseQuery(object): | |||||
self.user = None | self.user = None | ||||
self.flags = frappe._dict() | self.flags = frappe._dict() | ||||
def execute(self, query=None, filters=None, fields=None, or_filters=None, | |||||
def execute(self, query=None, fields=None, filters=None, or_filters=None, | |||||
docstatus=None, group_by=None, order_by=None, limit_start=0, | docstatus=None, group_by=None, order_by=None, limit_start=0, | ||||
limit_page_length=20, as_list=False, with_childnames=False, debug=False, | limit_page_length=20, as_list=False, with_childnames=False, debug=False, | ||||
ignore_permissions=False, user=None): | ignore_permissions=False, user=None): | ||||