Added warehouse to BOM Stock Report, fixed bugs with buildable qty

This commit is contained in:
Ben Cornwell-Mott 2017-02-09 23:21:52 -08:00
parent 630882787a
commit 67a13972fb
4 changed files with 23 additions and 17 deletions

View File

@ -4,7 +4,13 @@ frappe.query_reports["BOM Stock Report"] = {
"fieldname":"bom",
"label": __("BOM"),
"fieldtype": "Link",
"options": "BOM"
},
"options": "BOM",
"reqd": 1
},{
"fieldname":"warehouse",
"label": __("Warehouse"),
"fieldtype": "Link",
"reqd": 1
}
]
}

View File

@ -8,12 +8,12 @@
"idx": 0,
"is_standard": "Yes",
"letter_head": "Standard",
"modified": "2017-02-07 09:10:10.954616",
"modified": "2017-02-09 23:19:32.050905",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM Stock Report",
"owner": "Administrator",
"query": "SELECT \n\tbom_item.item_code as \"Item:Link/Item:200\",\n\tbom_item.description as \"Description:Data:300\",\n\tROUND(bom_item.qty * conf_item.conversion_factor,2) as \"Required Qty:Float:100\",\n\tROUND(ledger.actual_qty * conf_ledger.conversion_factor,2) as \"In Stock Qty:Float:100\",\n\tFLOOR((ledger.actual_qty * conf_ledger.conversion_factor)/(bom_item.qty * \t\t \tconf_item.conversion_factor)) as \"Enough Parts to Build:Int:100\"\nFROM\n\t`tabBOM Item` AS bom_item \n\tLEFT JOIN `tabBin` AS ledger\t\n\tON bom_item.item_code = ledger.item_code AND ledger.warehouse = %(warehouse)s\n\tLEFT JOIN `tabUOM Conversion Detail` AS conf_item\n\tON conf_item.parent = bom_item.item_code AND conf_item.uom = bom_item.stock_uom\n\tLEFT JOIN `tabUOM Conversion Detail` AS conf_ledger\n\tON conf_ledger.parent = ledger.item_code AND conf_ledger.uom = ledger.stock_uom\nWHERE\n\tbom_item.parent=%(bom)s\n\nGROUP BY bom_item.item_code",
"query": "SELECT \n\tbom_item.item_code as \"Item:Link/Item:200\",\n\tbom_item.description as \"Description:Data:300\",\n\tbom_item.qty as \"Required Qty:Float:100\",\n\tledger.actual_qty as \"In Stock Qty:Float:100\",\n\tFLOOR(ledger.actual_qty /bom_item.qty) as \"Enough Parts to Build:Int:100\"\nFROM\n\t`tabBOM Item` AS bom_item \n\tLEFT JOIN `tabBin` AS ledger\t\n\t\tON bom_item.item_code = ledger.item_code \n\t\tAND ledger.warehouse = %(warehouse)s\nWHERE\n\tbom_item.parent=%(bom)s\n\nGROUP BY bom_item.item_code",
"ref_doctype": "BOM",
"report_name": "BOM Stock Report",
"report_type": "Query Report"

View File

@ -7,8 +7,7 @@ frappe.query_reports["Production Order Stock Report"] = {
"fieldname":"warehouse",
"label": __("Warehouse"),
"fieldtype": "Link",
"options": "Warehouse",
"default": "Stores - VMI"
"options": "Warehouse"
}
]

View File

@ -26,7 +26,7 @@ def get_item_list(prod_list, filters):
produced_value = frappe.db.get_value("Production Order", prod_order.name, "produced_qty")
item_list = frappe.db.sql("""SELECT
bom_item.item_code as item_code,
ifnull(ledger.actual_qty,0)/(bom_item.qty) as build_qty
ifnull(ledger.actual_qty/bom_item.qty,0) as build_qty
FROM
`tabBOM Item` AS bom_item
LEFT JOIN `tabBin` AS ledger
@ -43,8 +43,9 @@ def get_item_list(prod_list, filters):
count = count + 1
if item.build_qty >= (qty-produced_value):
stock_qty = stock_qty + 1
elif buildable_qty > item.build_qty:
buidable_qty = item.build_qty
elif buildable_qty >= item.build_qty:
buildable_qty = item.build_qty
if count == stock_qty:
build = "Y"
@ -84,13 +85,13 @@ def get_columns():
"label": "BOM",
"fieldtype": "Link",
"options": "BOM",
"width": 130
"width": 120
}, {
"fieldname": "description",
"label": "Description",
"fieldtype": "Data",
"options": "",
"width": 250
"width": 230
}, {
"fieldname": "qty",
"label": "Qty to Build",
@ -102,19 +103,19 @@ def get_columns():
"label": "Status",
"fieldtype": "Data",
"options": "",
"width": 110
"width": 100
}, {
"fieldname": "req_items",
"label": "# of Required Items",
"label": "# Req'd Items",
"fieldtype": "Data",
"options": "",
"width": 135
"width": 105
}, {
"fieldname": "instock",
"label": "# of In Stock Items",
"label": "# In Stock",
"fieldtype": "Data",
"options": "",
"width": 135
"width": 105
}, {
"fieldname": "buildable_qty",
"label": "Buildable Qty",
@ -123,7 +124,7 @@ def get_columns():
"width": 100
}, {
"fieldname": "ready_to_build",
"label": "Can Build All",
"label": "Build All?",
"fieldtype": "Data",
"options": "",
"width": 90