Merge branch 'responsive' of git://github.com/saurabh6790/wnframework into saurabh1

This commit is contained in:
Nabin Hait 2013-07-10 19:03:39 +05:30
commit ca4b031c57
5 changed files with 54 additions and 24 deletions

View file

@ -1,22 +1,21 @@
cur_frm.cscript.onload = function(doc) {
cur_frm.fields_dict.user.get_query = function() {
return "select name, concat_ws(' ', first_name, middle_name, last_name) \
from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and \
(%(key)s like \"%s\" or \
concat_ws(' ', first_name, middle_name, last_name) like \"%%%s\") \
limit 50";
return {
query: "core.doctype.communication.communication.get_user"
}
};
cur_frm.fields_dict.lead.get_query = function() {
return "select name, lead_name from `tabLead` \
where docstatus < 2 and \
(%(key)s like \"%s\" or lead_name like \"%%%s\" or \
company_name like \"%%%s\") \
order by lead_name asc limit 50";
return {
query: "core.doctype.communication.communication.get_user"
}
};
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query;
cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.customer_query" } }
cur_frm.fields_dict.supplier.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.supplier_query" } }
if(doc.content)
doc.content = wn.utils.escape_script_and_style(doc.content);

View file

@ -119,3 +119,29 @@ class DocType():
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def get_user(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond
return webnotes.conn.sql("""select name, concat_ws(' ', first_name, middle_name, last_name)
from `tabProfile`
where ifnull(enabled, 0)=1
and docstatus < 2
and (%(key)s like "%(txt)s"
or concat_ws(' ', first_name, middle_name, last_name) like "%(txt)s")
%(mcond)s
limit %(start)s, %(page_len)s """ % {'key': searchfield,
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),
'start': start, 'page_len': page_len})
def get_lead(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond
return webnotes.conn.sql(""" select name, lead_name from `tabLead`
where docstatus < 2
and (%(key)s like "%(txt)s"
or lead_name like "%(txt)s"
or company_name like "%(txt)s")
%(mcond)s
order by lead_name asc
limit %(start)s, %(page_len)s """ % {'key': searchfield,'txt': "%%%s%%" % txt,
'mcond':get_match_cond(doctype, searchfield), 'start': start,
'page_len': page_len})

View file

@ -55,10 +55,12 @@ cur_frm.cscript.label = function(doc){
cur_frm.fields_dict['dt'].get_query = function(doc, dt, dn) {
return 'SELECT name FROM `tabDocType` \
WHERE IFNULL(issingle,0)=0 AND \
module != "Core" AND \
name LIKE "%s%%" ORDER BY name ASC LIMIT 50';
return{
filters:[
['DocType', 'issingle', '=', 0],
['DocType', 'module', '!=', 'Core']
]
}
}
cur_frm.cscript.fieldtype = function(doc, dt, dn) {

View file

@ -42,13 +42,14 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
}
cur_frm.fields_dict.doc_type.get_query = function(doc, dt, dn) {
return 'SELECT name FROM `tabDocType` \
WHERE ((IFNULL(issingle,0)=0 AND \
IFNULL(in_create, 0)=0 AND \
name not in ("DocType", "DocField", "DocPerm", "Profile", "Role", "UserRole", "Page", \
"Page Role", "Module Def", "Print Format", "Report")) \
or name = "Item Group") \
AND name LIKE "%s%%" ORDER BY name ASC LIMIT 50';
return{
filters:[
['DocType', 'issingle', '=', 0],
['DocType', 'in_create', '=', 0],
['DocType', 'name', 'not in', 'DocType, DocField, DocPerm, Profile, Role, UserRole,\
Page, Page Role, Module Def, Print Format, Report']
]
}
}
cur_frm.cscript.refresh = function(doc, dt, dn) {

View file

@ -172,6 +172,8 @@ def build_conditions(doctype, fields, filters, docstatus):
def build_filter_conditions(filters, conditions):
"""build conditions from user filters"""
from webnotes.utils import cstr
global tables
if not tables: tables = []
for f in filters:
if isinstance(f, basestring):
@ -182,7 +184,7 @@ def build_filter_conditions(filters, conditions):
tables.append(tname)
# prepare in condition
if f[2]=='in':
if f[2] in ['in', 'not in']:
opts = ["'" + t.strip().replace("'", "\\'") + "'" for t in f[3].split(',')]
f[3] = "(" + ', '.join(opts) + ")"
conditions.append(tname + '.' + f[1] + " " + f[2] + " " + f[3])