Merge pull request #3484 from rmehta/bom-search-report
[report] BOM Search
This commit is contained in:
commit
123beb5a07
@ -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"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -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,
|
||||
|
0
erpnext/stock/report/bom_search/__init__.py
Normal file
0
erpnext/stock/report/bom_search/__init__.py
Normal file
42
erpnext/stock/report/bom_search/bom_search.js
Normal file
42
erpnext/stock/report/bom_search/bom_search.js
Normal file
@ -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",
|
||||
},
|
||||
]
|
||||
}
|
17
erpnext/stock/report/bom_search/bom_search.json
Normal file
17
erpnext/stock/report/bom_search/bom_search.json
Normal file
@ -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"
|
||||
}
|
43
erpnext/stock/report/bom_search/bom_search.py
Normal file
43
erpnext/stock/report/bom_search/bom_search.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user