[api] added frappe.client.get_list
This commit is contained in:
parent
be6b3f37a8
commit
575ec0015a
8 changed files with 35 additions and 12 deletions
|
|
@ -90,7 +90,7 @@ def handle():
|
|||
if frappe.local.form_dict.get('fields'):
|
||||
frappe.local.form_dict['fields'] = json.loads(frappe.local.form_dict['fields'])
|
||||
frappe.local.response.update({
|
||||
"data": frappe.call(frappe.widgets.reportview.execute,
|
||||
"data": frappe.call(frappe.client.get_list,
|
||||
doctype, **frappe.local.form_dict)})
|
||||
|
||||
if frappe.local.request.method=="POST":
|
||||
|
|
|
|||
|
|
@ -791,7 +791,7 @@ def run_tests(app=None, module=None, doctype=None, verbose=False, tests=(), driv
|
|||
import frappe.test_runner
|
||||
from frappe.utils import sel
|
||||
|
||||
sel.start(verbose, driver)
|
||||
#sel.start(verbose, driver)
|
||||
|
||||
ret = 1
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ import frappe.model
|
|||
import frappe.utils
|
||||
import json, os
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_list(doctype, fields=None, filters=None, order_by=None,
|
||||
limit_start=None, limit_page_length=None):
|
||||
return frappe.get_list(doctype, fields=fields, filters=filters, order_by=order_by,
|
||||
limit_start=limit_start, limit_page_length=limit_page_length)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get(doctype, name=None, filters=None):
|
||||
if filters and not name:
|
||||
|
|
|
|||
|
|
@ -217,11 +217,20 @@ class BaseDocument(object):
|
|||
|
||||
d = self.get_valid_dict()
|
||||
columns = d.keys()
|
||||
frappe.db.sql("""update `tab{doctype}`
|
||||
set {values} where name=%s""".format(
|
||||
doctype = self.doctype,
|
||||
values = ", ".join(["`"+c+"`=%s" for c in columns])
|
||||
), d.values() + [d.get("name")])
|
||||
try:
|
||||
frappe.db.sql("""update `tab{doctype}`
|
||||
set {values} where name=%s""".format(
|
||||
doctype = self.doctype,
|
||||
values = ", ".join(["`"+c+"`=%s" for c in columns])
|
||||
), d.values() + [d.get("name")])
|
||||
except Exception, e:
|
||||
if e.args[0]==1062:
|
||||
type, value, traceback = sys.exc_info()
|
||||
fieldname = str(e).split("'")[-2]
|
||||
frappe.msgprint(_("{0} must be unique".format(self.meta.get_label(fieldname))))
|
||||
raise frappe.ValidationError, (self.doctype, self.name, e), traceback
|
||||
else:
|
||||
raise
|
||||
|
||||
def db_set(self, fieldname, value):
|
||||
self.set(fieldname, value)
|
||||
|
|
|
|||
|
|
@ -223,10 +223,13 @@ class DatabaseQuery(object):
|
|||
if not isinstance(f, (list, tuple)):
|
||||
frappe.throw("Filter must be a tuple or list (in a list)")
|
||||
|
||||
if len(f) != 4:
|
||||
if len(f) == 3:
|
||||
f = (self.doctype, f[0], f[1], f[2])
|
||||
|
||||
elif len(f) != 4:
|
||||
frappe.throw("Filter must have 4 values (doctype, fieldname, condition, value): " + str(f))
|
||||
|
||||
return f
|
||||
return list(f)
|
||||
|
||||
def build_match_conditions(self, as_condition=True):
|
||||
"""add match conditions if applicable"""
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class DbTable:
|
|||
# if index key exists
|
||||
if frappe.db.sql("""show index from `{0}`
|
||||
where key_name=%s
|
||||
and Non_unique=%s""".format(self.name), (col.fieldname, 1 if col.unique else 0), debug=1):
|
||||
and Non_unique=%s""".format(self.name), (col.fieldname, 1 if col.unique else 0)):
|
||||
query.append("drop index `{}`".format(col.fieldname))
|
||||
|
||||
for col in self.set_default:
|
||||
|
|
|
|||
|
|
@ -190,7 +190,12 @@ frappe.ui.form.ControlInput = frappe.ui.form.Control.extend({
|
|||
me.disp_area && $(me.disp_area).toggle(false);
|
||||
$(me.input_area).toggle(true);
|
||||
$(me.input_area).find("input").prop("disabled", false);
|
||||
!me.has_input && me.make_input();
|
||||
if(!me.has_input) {
|
||||
me.make_input();
|
||||
if(me.df.on_make) {
|
||||
me.df.on_make(me);
|
||||
}
|
||||
};
|
||||
if(me.doctype && me.docname)
|
||||
me.set_input(me.value);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ frappe.ui.form.GridRow = Class.extend({
|
|||
<div class="panel-body">\
|
||||
<div class="form-area"></div>\
|
||||
<div class="toolbar footer-toolbar" style="margin-top: 15px">\
|
||||
<span class="text-muted"><a href="#" class="shortcuts"><i class="icon-keyboard"></i>' + __("Shortcuts") + '</a></span>\
|
||||
<span class="text-muted"><a href="#" class="shortcuts"> <i class="icon-keyboard"></i>' + __("Shortcuts") + '</a></span>\
|
||||
<span class="text-success pull-right grid-toggle-row" \
|
||||
title="'+__("Close")+'"\
|
||||
style="margin-left: 7px; cursor: pointer;">\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue