fix: indentation issue in the Production Plan Summary report (#38019)
fix: Production Plan Summary report
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js
index 72438dd..dd102b0 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.js
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js
@@ -89,10 +89,6 @@
frm.trigger("show_progress");
if (frm.doc.status !== "Completed") {
- frm.add_custom_button(__("Work Order Tree"), ()=> {
- frappe.set_route('Tree', 'Work Order', {production_plan: frm.doc.name});
- }, __('View'));
-
frm.add_custom_button(__("Production Plan Summary"), ()=> {
frappe.set_route('query-report', 'Production Plan Summary', {production_plan: frm.doc.name});
}, __('View'));
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 6b12a29..6efb762 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -828,8 +828,6 @@
# Combine subassembly items
sub_assembly_items_store = self.combine_subassembly_items(sub_assembly_items_store)
- sub_assembly_items_store.sort(key=lambda d: d.bom_level, reverse=True) # sort by bom level
-
for idx, row in enumerate(sub_assembly_items_store):
row.idx = idx + 1
self.append("sub_assembly_items", row)
diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py
index e9c6ee3..dd32c34 100644
--- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py
@@ -664,49 +664,6 @@
frappe.db.rollback()
- def test_subassmebly_sorting(self):
- "Test subassembly sorting in case of multiple items with nested BOMs."
- from erpnext.manufacturing.doctype.bom.test_bom import create_nested_bom
-
- prefix = "_TestLevel_"
- boms = {
- "Assembly": {
- "SubAssembly1": {
- "ChildPart1": {},
- "ChildPart2": {},
- },
- "ChildPart6": {},
- "SubAssembly4": {"SubSubAssy2": {"ChildPart7": {}}},
- },
- "MegaDeepAssy": {
- "SecretSubassy": {
- "SecretPart": {"VerySecret": {"SuperSecret": {"Classified": {}}}},
- },
- # ^ assert that this is
- # first item in subassy table
- },
- }
- create_nested_bom(boms, prefix=prefix)
-
- items = [prefix + item_code for item_code in boms.keys()]
- plan = create_production_plan(item_code=items[0], do_not_save=True)
- plan.append(
- "po_items",
- {
- "use_multi_level_bom": 1,
- "item_code": items[1],
- "bom_no": frappe.db.get_value("Item", items[1], "default_bom"),
- "planned_qty": 1,
- "planned_start_date": now_datetime(),
- },
- )
- plan.get_sub_assembly_items()
-
- bom_level_order = [d.bom_level for d in plan.sub_assembly_items]
- self.assertEqual(bom_level_order, sorted(bom_level_order, reverse=True))
- # lowest most level of subassembly should be first
- self.assertIn("SuperSecret", plan.sub_assembly_items[0].production_item)
-
def test_multiple_work_order_for_production_plan_item(self):
"Test producing Prod Plan (making WO) in parts."
diff --git a/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.js b/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.js
index 521543a..afe4a6e 100644
--- a/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.js
+++ b/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.js
@@ -22,9 +22,9 @@
"formatter": function(value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
- if (column.fieldname == "document_name") {
+ if (column.fieldname == "item_code") {
var color = data.pending_qty > 0 ? 'red': 'green';
- value = `<a style='color:${color}' href="#Form/${data['document_type']}/${data['document_name']}" data-doctype="${data['document_type']}">${data['document_name']}</a>`;
+ value = `<a style='color:${color}' href="/app/item/${data['item_code']}" data-doctype="Item">${data['item_code']}</a>`;
}
return value;
diff --git a/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py b/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py
index 2c8f82f..076690f 100644
--- a/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py
+++ b/erpnext/manufacturing/report/production_plan_summary/production_plan_summary.py
@@ -44,6 +44,7 @@
{
"indent": 0,
"item_code": row.item_code,
+ "sales_order": row.get("sales_order"),
"item_name": frappe.get_cached_value("Item", row.item_code, "item_name"),
"qty": row.planned_qty,
"document_type": "Work Order",
@@ -80,7 +81,7 @@
data.append(
{
- "indent": 1,
+ "indent": 1 + item.indent,
"item_code": item.production_item,
"item_name": item.item_name,
"qty": item.qty,
@@ -98,7 +99,7 @@
for row in frappe.get_all(
"Work Order",
filters={"production_plan": filters.get("production_plan")},
- fields=["name", "produced_qty", "production_plan", "production_item"],
+ fields=["name", "produced_qty", "production_plan", "production_item", "sales_order"],
):
order_details.setdefault((row.name, row.production_item), row)
@@ -118,10 +119,17 @@
"label": _("Finished Good"),
"fieldtype": "Link",
"fieldname": "item_code",
- "width": 300,
+ "width": 240,
"options": "Item",
},
- {"label": _("Item Name"), "fieldtype": "data", "fieldname": "item_name", "width": 100},
+ {"label": _("Item Name"), "fieldtype": "data", "fieldname": "item_name", "width": 150},
+ {
+ "label": _("Sales Order"),
+ "options": "Sales Order",
+ "fieldtype": "Link",
+ "fieldname": "sales_order",
+ "width": 100,
+ },
{
"label": _("Document Type"),
"fieldtype": "Link",
@@ -133,10 +141,16 @@
"label": _("Document Name"),
"fieldtype": "Dynamic Link",
"fieldname": "document_name",
- "width": 150,
+ "options": "document_type",
+ "width": 180,
},
{"label": _("BOM Level"), "fieldtype": "Int", "fieldname": "bom_level", "width": 100},
{"label": _("Order Qty"), "fieldtype": "Float", "fieldname": "qty", "width": 120},
- {"label": _("Received Qty"), "fieldtype": "Float", "fieldname": "produced_qty", "width": 160},
+ {
+ "label": _("Produced / Received Qty"),
+ "fieldtype": "Float",
+ "fieldname": "produced_qty",
+ "width": 200,
+ },
{"label": _("Pending Qty"), "fieldtype": "Float", "fieldname": "pending_qty", "width": 110},
]