From 36b63a44b9d74a010df1f6878cd4a812e64ca761 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 3 Sep 2013 15:33:56 +0530 Subject: [PATCH] [fix] [minor] profile query --- accounts/doctype/pos_setting/pos_setting.js | 2 +- controllers/queries.py | 29 +------------------ hr/doctype/employee/employee.js | 2 +- public/js/queries.js | 2 +- selling/doctype/lead/lead.js | 4 +-- .../authorization_rule/authorization_rule.js | 4 +-- 6 files changed, 8 insertions(+), 35 deletions(-) diff --git a/accounts/doctype/pos_setting/pos_setting.js b/accounts/doctype/pos_setting/pos_setting.js index 18f555b919..641b3ef1cf 100755 --- a/accounts/doctype/pos_setting/pos_setting.js +++ b/accounts/doctype/pos_setting/pos_setting.js @@ -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) { - return{ query:"controllers.queries.profile_query"} + return{ query:"core.doctype.profile.profile.profile_query"} } diff --git a/controllers/queries.py b/controllers/queries.py index 0e23d5cd1e..81040a25e3 100644 --- a/controllers/queries.py +++ b/controllers/queries.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import webnotes +from webnotes.widgets.reportview import get_match_cond def get_filters_cond(doctype, filters, conditions): if filters: @@ -22,34 +23,6 @@ def get_filters_cond(doctype, filters, conditions): 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 def employee_query(doctype, txt, searchfield, start, page_len, filters): return webnotes.conn.sql("""select name, employee_name from `tabEmployee` diff --git a/hr/doctype/employee/employee.js b/hr/doctype/employee/employee.js index 9ee7c618e6..05aec3efa3 100644 --- a/hr/doctype/employee/employee.js +++ b/hr/doctype/employee/employee.js @@ -6,7 +6,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({ setup: function() { this.setup_leave_approver_select(); 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) { return{ query:"controllers.queries.employee_query"} } }, diff --git a/public/js/queries.js b/public/js/queries.js index fbd294757f..d0346e0cbd 100644 --- a/public/js/queries.js +++ b/public/js/queries.js @@ -5,7 +5,7 @@ wn.provide("erpnext.queries"); $.extend(erpnext.queries, { profile: function() { - return { query: "controllers.queries.profile_query" }; + return { query: "core.doctype.profile.profile.profile_query" }; }, lead: function() { diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 9a86b22d63..a3ae783867 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -14,12 +14,12 @@ erpnext.LeadController = wn.ui.form.Controller.extend({ onload: function() { if(cur_frm.fields_dict.lead_owner.df.options.match(/^Profile/)) { 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/)) { 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')) { diff --git a/setup/doctype/authorization_rule/authorization_rule.js b/setup/doctype/authorization_rule/authorization_rule.js index 02747a0351..00f5260b38 100644 --- a/setup/doctype/authorization_rule/authorization_rule.js +++ b/setup/doctype/authorization_rule/authorization_rule.js @@ -69,10 +69,10 @@ cur_frm.cscript.transaction = 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) { - 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;