Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | // License: GNU General Public License v3. See license.txt |
Rushabh Mehta | 5e7ec20 | 2013-01-11 11:15:27 +0530 | [diff] [blame] | 3 | |
| 4 | // searches for enabled profiles |
Rushabh Mehta | 5e7ec20 | 2013-01-11 11:15:27 +0530 | [diff] [blame] | 5 | wn.provide("erpnext.queries"); |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 6 | $.extend(erpnext.queries, { |
| 7 | profile: function() { |
Anand Doshi | 36b63a4 | 2013-09-03 15:33:56 +0530 | [diff] [blame] | 8 | return { query: "core.doctype.profile.profile.profile_query" }; |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 9 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 10 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 11 | lead: function() { |
| 12 | return { query: "controllers.queries.lead_query" }; |
| 13 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 14 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 15 | customer: function() { |
| 16 | return { query: "controllers.queries.customer_query" }; |
| 17 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 18 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 19 | supplier: function() { |
| 20 | return { query: "controllers.queries.supplier_query" }; |
| 21 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 22 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 23 | account: function() { |
| 24 | return { query: "controllers.queries.account_query" }; |
| 25 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 26 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 27 | item: function() { |
| 28 | return { query: "controllers.queries.item_query" }; |
| 29 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 30 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 31 | bom: function() { |
| 32 | return { query: "controllers.queries.bom" }; |
| 33 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 34 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 35 | task: function() { |
| 36 | return { query: "projects.utils.query_task" }; |
| 37 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 38 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 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 Mehta | 5e7ec20 | 2013-01-11 11:15:27 +0530 | [diff] [blame] | 44 | |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 45 | return { filters: { customer: doc.customer } }; |
| 46 | }, |
Akhilesh Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 47 | |
Anand Doshi | d5d39ac | 2013-07-29 13:28:37 +0530 | [diff] [blame] | 48 | 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 Darjee | f7f20f6 | 2014-01-29 20:13:43 +0530 | [diff] [blame] | 56 | |
| 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 Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 66 | not_a_group_filter: function() { |
| 67 | return { filters: { is_group: "No" } }; |
| 68 | }, |
Anand Doshi | 61cad50 | 2013-07-18 13:26:27 +0530 | [diff] [blame] | 69 | }); |