blob: 6fa9ef5bc0e76dc3a19f0f7df83e35ada77b99ba [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302// License: GNU General Public License v3. See license.txt
Rushabh Mehta5e7ec202013-01-11 11:15:27 +05303
4// searches for enabled profiles
Rushabh Mehta5e7ec202013-01-11 11:15:27 +05305wn.provide("erpnext.queries");
Anand Doshi61cad502013-07-18 13:26:27 +05306$.extend(erpnext.queries, {
7 profile: function() {
Anand Doshi36b63a42013-09-03 15:33:56 +05308 return { query: "core.doctype.profile.profile.profile_query" };
Anand Doshi61cad502013-07-18 13:26:27 +05309 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053010
Anand Doshi61cad502013-07-18 13:26:27 +053011 lead: function() {
12 return { query: "controllers.queries.lead_query" };
13 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053014
Anand Doshi61cad502013-07-18 13:26:27 +053015 customer: function() {
16 return { query: "controllers.queries.customer_query" };
17 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053018
Anand Doshi61cad502013-07-18 13:26:27 +053019 supplier: function() {
20 return { query: "controllers.queries.supplier_query" };
21 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053022
Anand Doshi61cad502013-07-18 13:26:27 +053023 account: function() {
24 return { query: "controllers.queries.account_query" };
25 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053026
Anand Doshi61cad502013-07-18 13:26:27 +053027 item: function() {
28 return { query: "controllers.queries.item_query" };
29 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053030
Anand Doshi61cad502013-07-18 13:26:27 +053031 bom: function() {
32 return { query: "controllers.queries.bom" };
33 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053034
Anand Doshi61cad502013-07-18 13:26:27 +053035 task: function() {
36 return { query: "projects.utils.query_task" };
37 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053038
Anand Doshi61cad502013-07-18 13:26:27 +053039 customer_filter: function(doc) {
40 if(!doc.customer) {
41 wn.throw(wn._("Please specify a") + " " +
42 wn._(wn.meta.get_label(doc.doctype, "customer", doc.name)));
43 }
Rushabh Mehta5e7ec202013-01-11 11:15:27 +053044
Anand Doshi61cad502013-07-18 13:26:27 +053045 return { filters: { customer: doc.customer } };
46 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053047
Anand Doshid5d39ac2013-07-29 13:28:37 +053048 supplier_filter: function(doc) {
49 if(!doc.supplier) {
50 wn.throw(wn._("Please specify a") + " " +
51 wn._(wn.meta.get_label(doc.doctype, "supplier", doc.name)));
52 }
53
54 return { filters: { supplier: doc.supplier } };
55 },
Akhilesh Darjeef7f20f62014-01-29 20:13:43 +053056
57 lead_filter: function(doc) {
58 if(!doc.lead) {
59 wn.throw(wn._("Please specify a") + " " +
60 wn._(wn.meta.get_label(doc.doctype, "lead", doc.name)));
61 }
62
63 return { filters: { lead: doc.lead } };
64 },
65
Anand Doshi61cad502013-07-18 13:26:27 +053066 not_a_group_filter: function() {
67 return { filters: { is_group: "No" } };
68 },
Anand Doshi61cad502013-07-18 13:26:27 +053069});