feat: added report for showinrg complete hierarchy of bom with item details and scraps
This commit is contained in:
parent
9706aaab65
commit
f1f2a3eed0
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
/* eslint-disable */
|
||||
|
||||
frappe.query_reports["BOM Items and Scraps"] = {
|
||||
"filters": [
|
||||
{
|
||||
fieldname: "bom",
|
||||
label: __("BOM"),
|
||||
fieldtype: "Link",
|
||||
options: "BOM",
|
||||
reqd: 1
|
||||
},
|
||||
]
|
||||
};
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"creation": "2019-05-14 12:06:14.998746",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2019-05-14 12:06:14.998746",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "BOM Items and Scraps",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"ref_doctype": "BOM",
|
||||
"report_name": "BOM Items and Scraps ",
|
||||
"report_type": "Script Report",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Manufacturing Manager"
|
||||
},
|
||||
{
|
||||
"role": "Manufacturing User"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from pprint import pprint
|
||||
|
||||
def execute(filters=None):
|
||||
data = []
|
||||
columns = get_columns()
|
||||
get_data(filters, data)
|
||||
return columns, data
|
||||
|
||||
def get_data(filters, data):
|
||||
get_exploded_items(filters.bom, data)
|
||||
|
||||
|
||||
|
||||
def get_exploded_items(bom, data, indent=1):
|
||||
exploded_items = frappe.get_all("BOM Item", filters={"parent": bom}, fields= ['qty','bom_no','qty','scrap','item_code','item_name','description','uom'])
|
||||
for item in exploded_items:
|
||||
item["indent"] = indent
|
||||
data.append({
|
||||
'item_code': item.item_code,
|
||||
'item_name': item.item_name,
|
||||
'indent': indent,
|
||||
'bom': item.bom_no,
|
||||
'qty': item.qty,
|
||||
'uom': item.uom,
|
||||
'description': item.description,
|
||||
'scrap': item.scrap
|
||||
})
|
||||
if item.bom_no:
|
||||
get_exploded_items(item.bom_no, data, indent=indent+1)
|
||||
|
||||
def get_columns():
|
||||
return [
|
||||
{
|
||||
"label": "Item Code",
|
||||
"fieldtype": "Link",
|
||||
"fieldname": "item_code",
|
||||
"width": 300,
|
||||
"options": "Item"
|
||||
},
|
||||
{
|
||||
"label": "Item Name",
|
||||
"fieldtype": "data",
|
||||
"fieldname": "item_name",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": "BOM",
|
||||
"fieldtype": "Link",
|
||||
"fieldname": "bom",
|
||||
"width": 150,
|
||||
"options": "BOM"
|
||||
},
|
||||
{
|
||||
"label": "Qty",
|
||||
"fieldtype": "data",
|
||||
"fieldname": "qty",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": "UOM",
|
||||
"fieldtype": "data",
|
||||
"fieldname": "uom",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": "Standard Description",
|
||||
"fieldtype": "data",
|
||||
"fieldname": "description",
|
||||
"width": 150
|
||||
},
|
||||
{
|
||||
"label": "Scrap",
|
||||
"fieldtype": "data",
|
||||
"fieldname": "scrap",
|
||||
"width": 100
|
||||
},
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user