From e30b2f1d04f5e8346cf12c845914c06dc9c701e5 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 e069aea274a..f3f42d6551c 100644 --- a/erpnext/manufacturing/doctype/routing/test_routing.py +++ b/erpnext/manufacturing/doctype/routing/test_routing.py @@ -56,7 +56,6 @@ class TestRouting(FrappeTestCase): 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 12e2ac8b7f4..14c458015be 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -517,7 +517,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( @@ -531,7 +530,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() def create_serial_no_batch_no(self): if not (self.has_serial_no or self.has_batch_no): @@ -588,13 +586,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 @@ -1027,10 +1018,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)