diff --git a/erpnext/config/manufacturing.py b/erpnext/config/manufacturing.py index c2dacad495..5b51b0f967 100644 --- a/erpnext/config/manufacturing.py +++ b/erpnext/config/manufacturing.py @@ -103,6 +103,12 @@ def get_data(): "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 7f8d517ae9..78c73d8822 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -237,6 +237,12 @@ def get_data(): "route": "query-report/Sales Person Target Variance Item Group-Wise", "doctype": "Sales Person", }, + { + "type": "report", + "is_query_report": True, + "name": "BOM Search", + "doctype": "BOM" + }, { "type": "report", "is_query_report": True, diff --git a/erpnext/stock/report/bom_search/__init__.py b/erpnext/stock/report/bom_search/__init__.py new file mode 100644 index 0000000000..e69de29bb2 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 0000000000..e9e763cb88 --- /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 0000000000..2857c176d3 --- /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 0000000000..b8a7b789e5 --- /dev/null +++ b/erpnext/stock/report/bom_search/bom_search.py @@ -0,0 +1,43 @@ +# 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 = [] + parents = { + "Sales BOM Item": "Sales BOM", + "BOM Explosion Item": "BOM", + "BOM Item": "BOM" + } + + 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, parents[doctype])) + + return [{ + "fieldname": "parent", + "label": "BOM", + "width": 200, + "fieldtype": "Dynamic Link", + "options": "doctype" + }, + { + "fieldname": "doctype", + "label": "Type", + "width": 200, + "fieldtype": "Data" + }], data