[report] BOM Search
diff --git a/erpnext/config/manufacturing.py b/erpnext/config/manufacturing.py
index c2dacad..5b51b0f 100644
--- a/erpnext/config/manufacturing.py
+++ b/erpnext/config/manufacturing.py
@@ -103,6 +103,12 @@
"name": "Completed Production Orders",
"doctype": "Production Order"
},
+ {
+ "type": "report",
+ "is_query_report": True,
+ "name": "BOM Search",
+ "doctype": "BOM"
+ },
]
},
{
diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py
index 7f8d517..78c73d8 100644
--- a/erpnext/config/selling.py
+++ b/erpnext/config/selling.py
@@ -240,6 +240,12 @@
{
"type": "report",
"is_query_report": True,
+ "name": "BOM Search",
+ "doctype": "BOM"
+ },
+ {
+ "type": "report",
+ "is_query_report": True,
"name": "Customers Not Buying Since Long Time",
"doctype": "Sales Order"
},
diff --git a/erpnext/stock/report/bom_search/__init__.py b/erpnext/stock/report/bom_search/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/stock/report/bom_search/__init__.py
diff --git a/erpnext/stock/report/bom_search/bom_search.js b/erpnext/stock/report/bom_search/bom_search.js
new file mode 100644
index 0000000..e9e763c
--- /dev/null
+++ b/erpnext/stock/report/bom_search/bom_search.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors and contributors
+// For license information, please see license.txt
+
+frappe.query_reports["BOM Search"] = {
+ "filters": [
+ {
+ fieldname: "item1",
+ label: __("Item 1"),
+ fieldtype: "Link",
+ options: "Item"
+ },
+ {
+ fieldname: "item2",
+ label: __("Item 2"),
+ fieldtype: "Link",
+ options: "Item"
+ },
+ {
+ fieldname: "item3",
+ label: __("Item 3"),
+ fieldtype: "Link",
+ options: "Item"
+ },
+ {
+ fieldname: "item4",
+ label: __("Item 4"),
+ fieldtype: "Link",
+ options: "Item"
+ },
+ {
+ fieldname: "item5",
+ label: __("Item 5"),
+ fieldtype: "Link",
+ options: "Item"
+ },
+ {
+ fieldname: "search_sub_assemblies",
+ label: __("Search Sub Assemblies"),
+ fieldtype: "Check",
+ },
+ ]
+}
diff --git a/erpnext/stock/report/bom_search/bom_search.json b/erpnext/stock/report/bom_search/bom_search.json
new file mode 100644
index 0000000..2857c17
--- /dev/null
+++ b/erpnext/stock/report/bom_search/bom_search.json
@@ -0,0 +1,17 @@
+{
+ "add_total_row": 0,
+ "apply_user_permissions": 0,
+ "creation": "2015-06-16 15:16:11.930954",
+ "disabled": 0,
+ "docstatus": 0,
+ "doctype": "Report",
+ "is_standard": "Yes",
+ "modified": "2015-06-16 15:16:29.850834",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "BOM Search",
+ "owner": "Administrator",
+ "ref_doctype": "BOM",
+ "report_name": "BOM Search",
+ "report_type": "Script Report"
+}
\ No newline at end of file
diff --git a/erpnext/stock/report/bom_search/bom_search.py b/erpnext/stock/report/bom_search/bom_search.py
new file mode 100644
index 0000000..cf1e339
--- /dev/null
+++ b/erpnext/stock/report/bom_search/bom_search.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe, json
+
+def execute(filters=None):
+ data = []
+
+ for doctype in ("Sales BOM Item",
+ "BOM Explosion Item" if filters.search_sub_assemblies else "BOM Item"):
+ all_boms = {}
+ for d in frappe.get_all(doctype, fields=["parent", "item_code"]):
+ all_boms.setdefault(d.parent, []).append(d.item_code)
+
+ for parent, items in all_boms.iteritems():
+ valid = True
+ for key, item in filters.iteritems():
+ if key != "search_sub_assemblies":
+ if item and item not in items:
+ valid = False
+
+ if valid:
+ data.append((parent, doctype[:-5]))
+
+ return [{
+ "fieldname": "parent",
+ "label": "BOM",
+ "width": 200,
+ "fieldtype": "Dynamic Link",
+ "options": "doctype"
+ },
+ {
+ "fieldname": "doctype",
+ "label": "Type",
+ "width": 200,
+ "fieldtype": "Data"
+ }], data
+
+ #print json.dumps(all_boms, indent=1)
+ #columns, data = [], []
+ #return columns, data