diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 2f275bb3c91..8cad82c3e25 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -242,10 +242,11 @@ class StockController(AccountsController): _(self.doctype), self.name, item.get("item_code"))) def delete_auto_created_batches(self): + from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos for d in self.items: if not d.batch_no: continue - serial_nos = [sr.name for sr in frappe.get_all("Serial No", {'batch_no': d.batch_no})] + serial_nos = get_serial_nos(d.serial_no) if serial_nos: frappe.db.set_value("Serial No", { 'name': ['in', serial_nos] }, "batch_no", None) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 0dc87767dde..00dc7725039 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -45,6 +45,7 @@ class StockReconciliation(StockController): def on_cancel(self): self.delete_and_repost_sle() self.make_gl_entries_on_cancel() + self.delete_auto_created_batches() def remove_items_with_no_change(self): """Remove items if qty or rate is not changed"""