From 9ff924e8317a221a6c29ff90e652ca85ba84343b Mon Sep 17 00:00:00 2001 From: Sudharsanan Ashok <135326972+Sudharsanan11@users.noreply.github.com> Date: Mon, 23 Feb 2026 16:58:13 +0530 Subject: [PATCH] fix(manufacturing): remove delete query of job card & batch and serial no (#52840) * fix(manufacturing): remove delete query of batch and serial no * fix(manufacturing): remove delete query of job card * fix: remove delete function call for work order (cherry picked from commit 8b2a9710190a108022da0375ecf19f99504a4ba8) --- .../manufacturing/doctype/routing/test_routing.py | 1 - .../manufacturing/doctype/work_order/work_order.py | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/erpnext/manufacturing/doctype/routing/test_routing.py b/erpnext/manufacturing/doctype/routing/test_routing.py index 27dcade6195..4c6e8df5752 100644 --- a/erpnext/manufacturing/doctype/routing/test_routing.py +++ b/erpnext/manufacturing/doctype/routing/test_routing.py @@ -56,7 +56,6 @@ class TestRouting(IntegrationTestCase): self.assertEqual(job_card_doc.total_completed_qty, 10) wo_doc.cancel() - wo_doc.delete() def test_update_bom_operation_time(self): """Update cost shouldn't update routing times.""" diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 394dee15e7a..b442f5becfc 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -780,7 +780,6 @@ class WorkOrder(Document): self.db_set("status", "Cancelled") self.on_close_or_cancel() - self.delete_job_card() def on_close_or_cancel(self): if self.production_plan and frappe.db.exists( @@ -794,7 +793,6 @@ class WorkOrder(Document): self.update_planned_qty() self.update_ordered_qty() self.update_reserved_qty_for_production() - self.delete_auto_created_batch_and_serial_no() if self.reserve_stock: self.update_stock_reservation() @@ -926,13 +924,6 @@ class WorkOrder(Document): ) ) - def delete_auto_created_batch_and_serial_no(self): - for row in frappe.get_all("Serial No", filters={"work_order": self.name}): - frappe.delete_doc("Serial No", row.name) - - for row in frappe.get_all("Batch", filters={"reference_name": self.name}): - frappe.delete_doc("Batch", row.name) - def make_serial_nos(self, args): item_details = frappe.get_cached_value( "Item", self.production_item, ["serial_no_series", "item_name", "description"], as_dict=1 @@ -1384,10 +1375,6 @@ class WorkOrder(Document): if self.actual_start_date and self.actual_end_date: self.lead_time = flt(time_diff_in_hours(self.actual_end_date, self.actual_start_date) * 60) - def delete_job_card(self): - for d in frappe.get_all("Job Card", ["name"], {"work_order": self.name}): - frappe.delete_doc("Job Card", d.name) - def validate_production_item(self): if frappe.get_cached_value("Item", self.production_item, "has_variants"): frappe.throw(_("Work Order cannot be raised against a Item Template"), ItemHasVariantError)