blob: 3c60a9149af3e301e51d5e00f17e483c888e2e04 [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 },
10
11 lead: function() {
12 return { query: "controllers.queries.lead_query" };
13 },
14
15 customer: function() {
16 return { query: "controllers.queries.customer_query" };
17 },
18
19 supplier: function() {
20 return { query: "controllers.queries.supplier_query" };
21 },
22
23 account: function() {
24 return { query: "controllers.queries.account_query" };
25 },
26
27 item: function() {
28 return { query: "controllers.queries.item_query" };
29 },
30
31 bom: function() {
32 return { query: "controllers.queries.bom" };
33 },
34
35 task: function() {
36 return { query: "projects.utils.query_task" };
37 },
38
39 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 },
Rushabh Mehta5e7ec202013-01-11 11:15:27 +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 },
56
Anand Doshi61cad502013-07-18 13:26:27 +053057 not_a_group_filter: function() {
58 return { filters: { is_group: "No" } };
59 },
Rushabh Mehta5e7ec202013-01-11 11:15:27 +053060
Anand Doshi61cad502013-07-18 13:26:27 +053061});