2013-11-20 12:59:58 +05:30
|
|
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
2013-08-05 14:59:54 +05:30
|
|
|
// License: GNU General Public License v3. See license.txt
|
2013-01-11 11:15:27 +05:30
|
|
|
|
2014-03-11 16:15:05 +05:30
|
|
|
// searches for enabled users
|
2014-02-14 15:47:51 +05:30
|
|
|
frappe.provide("erpnext.queries");
|
2013-07-18 13:26:27 +05:30
|
|
|
$.extend(erpnext.queries, {
|
2014-03-11 16:15:05 +05:30
|
|
|
user: function() {
|
|
|
|
return { query: "frappe.core.doctype.user.user.user_query" };
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
lead: function() {
|
2013-12-13 14:10:14 +05:30
|
|
|
return { query: "erpnext.controllers.queries.lead_query" };
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
customer: function() {
|
2013-12-13 14:10:14 +05:30
|
|
|
return { query: "erpnext.controllers.queries.customer_query" };
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
supplier: function() {
|
2013-12-13 14:10:14 +05:30
|
|
|
return { query: "erpnext.controllers.queries.supplier_query" };
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2014-04-16 15:21:46 +05:30
|
|
|
item: function(filters) {
|
|
|
|
var args = { query: "erpnext.controllers.queries.item_query" };
|
|
|
|
if(filters) args["filters"] = filters;
|
|
|
|
return args;
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
bom: function() {
|
2013-12-13 14:10:14 +05:30
|
|
|
return { query: "erpnext.controllers.queries.bom" };
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
task: function() {
|
2014-01-30 13:56:57 +05:30
|
|
|
return { query: "erpnext.projects.utils.query_task" };
|
2013-07-18 13:26:27 +05:30
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
customer_filter: function(doc) {
|
|
|
|
if(!doc.customer) {
|
2014-04-16 15:21:46 +05:30
|
|
|
frappe.throw(__("Please specify a") + " " +
|
2014-04-14 16:25:30 +05:30
|
|
|
__(frappe.meta.get_label(doc.doctype, "customer", doc.name)));
|
2013-07-18 13:26:27 +05:30
|
|
|
}
|
2014-04-16 15:21:46 +05:30
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
return { filters: { customer: doc.customer } };
|
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
2013-07-29 13:28:37 +05:30
|
|
|
supplier_filter: function(doc) {
|
|
|
|
if(!doc.supplier) {
|
2014-04-16 15:21:46 +05:30
|
|
|
frappe.throw(__("Please specify a") + " " +
|
2014-04-14 16:25:30 +05:30
|
|
|
__(frappe.meta.get_label(doc.doctype, "supplier", doc.name)));
|
2013-07-29 13:28:37 +05:30
|
|
|
}
|
2014-04-16 15:21:46 +05:30
|
|
|
|
2013-07-29 13:28:37 +05:30
|
|
|
return { filters: { supplier: doc.supplier } };
|
|
|
|
},
|
2014-01-29 20:13:43 +05:30
|
|
|
|
|
|
|
lead_filter: function(doc) {
|
|
|
|
if(!doc.lead) {
|
2014-04-16 15:21:46 +05:30
|
|
|
frappe.throw(__("Please specify a") + " " +
|
2014-04-14 16:25:30 +05:30
|
|
|
__(frappe.meta.get_label(doc.doctype, "lead", doc.name)));
|
2014-01-29 20:13:43 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return { filters: { lead: doc.lead } };
|
|
|
|
},
|
|
|
|
|
2013-07-18 13:26:27 +05:30
|
|
|
not_a_group_filter: function() {
|
|
|
|
return { filters: { is_group: "No" } };
|
|
|
|
},
|
2014-05-02 16:20:45 +05:30
|
|
|
|
|
|
|
employee: function() {
|
|
|
|
return { query: "erpnext.controllers.queries.employee_query" }
|
2014-06-24 18:53:04 +05:30
|
|
|
},
|
|
|
|
|
|
|
|
warehouse: function(doc) {
|
|
|
|
return {
|
2014-07-14 12:39:50 +05:30
|
|
|
filters: [["Warehouse", "company", "in", ["", cstr(doc.company)]]]
|
2014-06-24 18:53:04 +05:30
|
|
|
}
|
2014-05-02 16:20:45 +05:30
|
|
|
}
|
2014-04-16 15:21:46 +05:30
|
|
|
});
|