From b638aed7588b2237648a6c109819e6dfb489c99e Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Fri, 14 Mar 2025 23:51:30 +0530 Subject: [PATCH] fix: exclude current doc when checking for duplicate (cherry picked from commit d8ef5e4d580f3e5764a2c9e00fe051975c5a7e82) --- .../manufacturing/doctype/work_order/test_work_order.py | 1 + erpnext/stock/doctype/stock_entry/stock_entry.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py index 205ca1dbdb4..84f2b75432c 100644 --- a/erpnext/manufacturing/doctype/work_order/test_work_order.py +++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py @@ -42,6 +42,7 @@ class TestWorkOrder(FrappeTestCase): prepare_data_for_backflush_based_on_materials_transferred() def tearDown(self): + frappe.local.future_sle = {} frappe.db.rollback() def check_planned_qty(self): diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 9b5f9dc9810..3f548a1324d 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -913,7 +913,12 @@ class StockEntry(StockController): if frappe.db.exists( "Stock Entry", - {"docstatus": 1, "work_order": self.work_order, "purpose": "Manufacture"}, + { + "docstatus": 1, + "work_order": self.work_order, + "purpose": "Manufacture", + "name": ("!=", self.name), + }, ): frappe.throw( _("Only one {0} entry can be created against the Work Order {1}").format(