[fix] [minor] profile query

This commit is contained in:
Anand Doshi 2013-09-03 15:33:56 +05:30
parent 86f3da1a77
commit 36b63a44b9
6 changed files with 8 additions and 35 deletions

View File

@ -70,5 +70,5 @@ cur_frm.fields_dict["expense_account"].get_query = function(doc) {
} }
cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) { cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.profile_query"} return{ query:"core.doctype.profile.profile.profile_query"}
} }

View File

@ -3,6 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.widgets.reportview import get_match_cond
def get_filters_cond(doctype, filters, conditions): def get_filters_cond(doctype, filters, conditions):
if filters: if filters:
@ -22,34 +23,6 @@ def get_filters_cond(doctype, filters, conditions):
cond = '' cond = ''
return cond return cond
def get_match_cond(doctype, searchfield = 'name'):
from webnotes.widgets.reportview import build_match_conditions
cond = build_match_conditions(doctype)
if cond:
cond = ' and ' + cond
else:
cond = ''
return cond
# searches for enabled profiles
def profile_query(doctype, txt, searchfield, start, page_len, filters):
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 name not in ('Administrator', 'Guest')
and (%(key)s like "%(txt)s"
or concat_ws(' ', first_name, middle_name, last_name) like "%(txt)s")
%(mcond)s
order by
case when name like "%(txt)s" then 0 else 1 end,
case when concat_ws(' ', first_name, middle_name, last_name) like "%(txt)s"
then 0 else 1 end,
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})
# searches for active employees # searches for active employees
def employee_query(doctype, txt, searchfield, start, page_len, filters): def employee_query(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select name, employee_name from `tabEmployee` return webnotes.conn.sql("""select name, employee_name from `tabEmployee`

View File

@ -6,7 +6,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
setup: function() { setup: function() {
this.setup_leave_approver_select(); this.setup_leave_approver_select();
this.frm.fields_dict.user_id.get_query = function(doc,cdt,cdn) { this.frm.fields_dict.user_id.get_query = function(doc,cdt,cdn) {
return { query:"controllers.queries.profile_query"} } return { query:"core.doctype.profile.profile.profile_query"} }
this.frm.fields_dict.reports_to.get_query = function(doc,cdt,cdn) { this.frm.fields_dict.reports_to.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.employee_query"} } return{ query:"controllers.queries.employee_query"} }
}, },

View File

@ -5,7 +5,7 @@
wn.provide("erpnext.queries"); wn.provide("erpnext.queries");
$.extend(erpnext.queries, { $.extend(erpnext.queries, {
profile: function() { profile: function() {
return { query: "controllers.queries.profile_query" }; return { query: "core.doctype.profile.profile.profile_query" };
}, },
lead: function() { lead: function() {

View File

@ -14,12 +14,12 @@ erpnext.LeadController = wn.ui.form.Controller.extend({
onload: function() { onload: function() {
if(cur_frm.fields_dict.lead_owner.df.options.match(/^Profile/)) { if(cur_frm.fields_dict.lead_owner.df.options.match(/^Profile/)) {
cur_frm.fields_dict.lead_owner.get_query = function(doc,cdt,cdn) { cur_frm.fields_dict.lead_owner.get_query = function(doc,cdt,cdn) {
return { query:"controllers.queries.profile_query" } } return { query:"core.doctype.profile.profile.profile_query" } }
} }
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) { if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
cur_frm.fields_dict.contact_by.get_query = function(doc,cdt,cdn) { cur_frm.fields_dict.contact_by.get_query = function(doc,cdt,cdn) {
return { query:"controllers.queries.profile_query" } } return { query:"core.doctype.profile.profile.profile_query" } }
} }
if(in_list(user_roles,'System Manager')) { if(in_list(user_roles,'System Manager')) {

View File

@ -69,10 +69,10 @@ cur_frm.cscript.transaction = function(doc,cdt,cdn){
cur_frm.fields_dict.system_user.get_query = function(doc,cdt,cdn) { cur_frm.fields_dict.system_user.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.profile_query" } } return{ query:"core.doctype.profile.profile.profile_query" } }
cur_frm.fields_dict.approving_user.get_query = function(doc,cdt,cdn) { cur_frm.fields_dict.approving_user.get_query = function(doc,cdt,cdn) {
return{ query:"controllers.queries.profile_query" } } return{ query:"core.doctype.profile.profile.profile_query" } }
cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query; cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query;