From a1fe6cee5d8b54464a8d5c1f42937522dc4675df Mon Sep 17 00:00:00 2001 From: pandiyan Date: Fri, 3 Jul 2026 12:29:25 +0530 Subject: [PATCH 1/3] fix: remove company default on cost center in stock entry detail the ":company" default pre-filled every row before set_default_cost_center() ran, so its "if not row.cost_center" guard was always false and the project/item group/brand priority chain in get_default_cost_center() never ran. (cherry picked from commit edfa0a7a1d599a9f20406b3b114f8c666148e4f0) # Conflicts: # erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json --- .../stock/doctype/stock_entry_detail/stock_entry_detail.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json index b41a7038b78..6af0a387f5c 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -345,7 +345,6 @@ "print_hide": 1 }, { - "default": ":Company", "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))", "fieldname": "cost_center", "fieldtype": "Link", @@ -679,7 +678,11 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2026-06-30 12:18:34.132425", +======= + "modified": "2026-07-03 12:11:53.714931", +>>>>>>> edfa0a7a1d (fix: remove company default on cost center in stock entry detail) "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Detail", From 149af49d011abf758f1a301a4d4a13e6da1d04c0 Mon Sep 17 00:00:00 2001 From: pandiyan Date: Fri, 3 Jul 2026 13:12:35 +0530 Subject: [PATCH 2/3] test: cover cost center fallback to item group default in manufacture entry the existing test_cost_center_for_manufacture only checks a raw material row against an item-level override, which is set independently of the ":company" default guard and never exercised the bug. (cherry picked from commit a168bb7ea49f669597aadcf898c35e1fd0cb2dbd) --- .../doctype/work_order/test_work_order.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py index 7233a1aea34..57d44084fd0 100644 --- a/erpnext/manufacturing/doctype/work_order/test_work_order.py +++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py @@ -686,6 +686,28 @@ class TestWorkOrder(ERPNextTestSuite): ste = make_stock_entry(wo_order.name, "Material Transfer for Manufacture", wo_order.qty) self.assertEqual(ste.get("items")[0].get("cost_center"), "_Test Cost Center - _TC") + @ERPNextTestSuite.change_settings("Manufacturing Settings", {"make_serial_no_batch_from_work_order": 0}) + def test_cost_center_for_manufacture_falls_back_to_item_group_default(self): + # "_Test Item Group" is master data with buying_cost_center already set to + # "_Test Cost Center 2 - _TC" for "_Test Company"; only the FG item and its + # BOM need to be created, since no existing item in that group has one. + fg_item = make_item( + "_Test FG Item For Item Group Cost Center", + {"is_stock_item": 1, "item_group": "_Test Item Group", "include_item_in_manufacturing": 1}, + ) + + if not frappe.db.exists("BOM", {"item": fg_item.name, "is_active": 1, "is_default": 1}): + make_bom(item=fg_item.name, raw_materials=["_Test Item"]) + + wo_order = make_wo_order_test_record( + production_item=fg_item.name, skip_transfer=1, source_warehouse="_Test Warehouse - _TC" + ) + ste = frappe.get_doc(make_stock_entry(wo_order.name, "Manufacture", wo_order.qty)) + ste.insert() + + fg_row = next(d for d in ste.items if d.is_finished_item) + self.assertEqual(fg_row.cost_center, "_Test Cost Center 2 - _TC") + def test_operation_time_with_batch_size(self): fg_item = "Test Batch Size Item For BOM" rm1 = "Test Batch Size Item RM 1 For BOM" From 3aad7fee24d658e40198e4c190241a67d0d19448 Mon Sep 17 00:00:00 2001 From: Pandiyan P Date: Sat, 4 Jul 2026 12:46:32 +0530 Subject: [PATCH 3/3] fix: resolve conflicts --- .../stock/doctype/stock_entry_detail/stock_entry_detail.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json index 6af0a387f5c..ce2bf227106 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -678,11 +678,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], -<<<<<<< HEAD - "modified": "2026-06-30 12:18:34.132425", -======= "modified": "2026-07-03 12:11:53.714931", ->>>>>>> edfa0a7a1d (fix: remove company default on cost center in stock entry detail) "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Detail",