From 81ed32ff51eff145293eca55203a2f131b8a41b5 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 8 Oct 2025 21:46:17 +0530 Subject: [PATCH] fix: Reset Raw Materials Table button not working (cherry picked from commit 128e243945457d36e720ffb4633113fdba172d93) --- erpnext/controllers/subcontracting_controller.py | 6 ++++++ .../subcontracting_receipt/subcontracting_receipt.js | 4 ++++ .../subcontracting_receipt/subcontracting_receipt.json | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py index da03f907e3b..4666c953fbe 100644 --- a/erpnext/controllers/subcontracting_controller.py +++ b/erpnext/controllers/subcontracting_controller.py @@ -201,6 +201,9 @@ class SubcontractingController(StockController): self.set(self.raw_material_table, []) return + if not self.get(self.raw_material_table): + return + item_dict = self.__get_data_before_save() if not item_dict: return True @@ -651,6 +654,9 @@ class SubcontractingController(StockController): from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos_for_outward from erpnext.stock.get_item_details import get_filtered_serial_nos + if self.is_return: + return + for row in self.supplied_items: item_details = frappe.get_cached_value( "Item", row.rm_item_code, ["has_batch_no", "has_serial_no"], as_dict=1 diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index c9fe457ef79..fee1cac2542 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -336,6 +336,10 @@ frappe.ui.form.on("Subcontracting Receipt", { reset_raw_materials_table: (frm) => { frm.clear_table("supplied_items"); + frm.doc.__unsaved = true; + if (!frm.doc.set_posting_time) { + frm.set_value("posting_time", frappe.datetime.now_time()); + } frm.call({ method: "reset_raw_materials", diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json index e975f384c25..dcc02f7a5a1 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json @@ -649,6 +649,7 @@ "label": "Raw Materials Actions" }, { + "description": "Click this button if you encounter a negative stock error for a serial or batch item. The system will fetch the available serials or batches automatically.", "fieldname": "reset_raw_materials_table", "fieldtype": "Button", "label": "Reset Raw Materials Table" @@ -678,7 +679,7 @@ "in_create": 1, "is_submittable": 1, "links": [], - "modified": "2024-12-06 15:24:38.384232", + "modified": "2025-10-08 21:43:27.065640", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Receipt", @@ -739,6 +740,7 @@ "write": 1 } ], + "row_format": "Dynamic", "search_fields": "status, posting_date, supplier", "show_name_in_global_search": 1, "sort_field": "modified",