diff --git a/erpnext/stock/report/process_loss_report/process_loss_report.js b/erpnext/stock/report/process_loss_report/process_loss_report.js index 078b9e11ce..b0c2b94a25 100644 --- a/erpnext/stock/report/process_loss_report/process_loss_report.js +++ b/erpnext/stock/report/process_loss_report/process_loss_report.js @@ -17,6 +17,13 @@ frappe.query_reports["Process Loss Report"] = { fieldname: "item", fieldtype: "Link", options: "Item", + mandatory: false, + }, + { + label: __("Work Order"), + fieldname: "work_order", + fieldtype: "Link", + options: "Work Order", mandatory: false, }, { diff --git a/erpnext/stock/report/process_loss_report/process_loss_report.py b/erpnext/stock/report/process_loss_report/process_loss_report.py index be0f0151d4..7494328ab4 100644 --- a/erpnext/stock/report/process_loss_report/process_loss_report.py +++ b/erpnext/stock/report/process_loss_report/process_loss_report.py @@ -43,12 +43,6 @@ def get_columns() -> Columns: 'fieldtype': 'Data', 'width': '100' }, - { - 'label': 'Qty To Manufacture', - 'fieldname': 'qty', - 'fieldtype': 'Float', - 'width': '150' - }, { 'label': 'Manufactured Qty', 'fieldname': 'produced_qty', @@ -56,7 +50,7 @@ def get_columns() -> Columns: 'width': '150' }, { - 'label': 'Process Loss Qty', + 'label': 'Loss Qty', 'fieldname': 'process_loss_qty', 'fieldtype': 'Float', 'width': '150' @@ -68,23 +62,23 @@ def get_columns() -> Columns: 'width': '150' }, { - 'label': 'Total FG Value', + 'label': 'Loss Value', + 'fieldname': 'total_pl_value', + 'fieldtype': 'Float', + 'width': '150' + }, + { + 'label': 'FG Value', 'fieldname': 'total_fg_value', 'fieldtype': 'Float', 'width': '150' }, { - 'label': 'Total Raw Material Value', + 'label': 'Raw Material Value', 'fieldname': 'total_rm_value', 'fieldtype': 'Float', 'width': '150' - }, - { - 'label': 'Total Process Loss Value', - 'fieldname': 'total_pl_value', - 'fieldtype': 'Float', - 'width': '150' - }, + } ] def get_query_args(filters: Filters) -> QueryArgs: @@ -111,10 +105,11 @@ def run_query(query_args: QueryArgs) -> Data: AND wo.company = %(company)s AND se.docstatus = 1 AND se.posting_date BETWEEN %(from_date)s AND %(to_date)s - %(item_filter)s + {item_filter} + {work_order_filter} GROUP BY se.work_order - """, query_args, as_dict=1) + """.format(**query_args), query_args, as_dict=1, debug=1) def update_data_with_total_pl_value(data: Data) -> None: for row in data: @@ -122,11 +117,16 @@ def update_data_with_total_pl_value(data: Data) -> None: row['total_pl_value'] = row['process_loss_qty'] * value_per_unit_fg def get_filter_conditions(filters: Filters) -> QueryArgs: - filter_conditions = dict(item_filter="") + filter_conditions = dict(item_filter="", work_order_filter="") if "item" in filters: production_item = filters.get("item") filter_conditions.update( - {"item_filter": f"wo.production_item='{production_item}'"} + {"item_filter": f"AND wo.production_item='{production_item}'"} + ) + if "work_order" in filters: + work_order_name = filters.get("work_order") + filter_conditions.update( + {"work_order_filter": f"AND wo.name='{work_order_name}'"} ) return filter_conditions