From b5cb12c3d7fa7b9fba5e17e5b9a6ed5bcb5d4420 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sat, 1 Aug 2026 14:40:14 +0530 Subject: [PATCH] fix(job_card): keep the stock uom backfill atomic Drop the auto commit toggle so the backfill is a single transaction with no connection flag left behind when it raises, and select the job cards to fill with an explicit unset filter instead of a value list. --- erpnext/patches/v16_0/set_stock_uom_in_job_card.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/erpnext/patches/v16_0/set_stock_uom_in_job_card.py b/erpnext/patches/v16_0/set_stock_uom_in_job_card.py index 7289ec6552e..35abf69df05 100644 --- a/erpnext/patches/v16_0/set_stock_uom_in_job_card.py +++ b/erpnext/patches/v16_0/set_stock_uom_in_job_card.py @@ -4,15 +4,14 @@ import frappe def execute(): job_cards = frappe.get_all( "Job Card", - filters={"stock_uom": ("in", ["", None])}, + filters={"stock_uom": ("is", "not set")}, fields=["name", "finished_good", "production_item"], ) if not job_cards: return - item_codes = {row.finished_good or row.production_item for row in job_cards} - item_codes.discard(None) + item_codes = {code for row in job_cards if (code := row.finished_good or row.production_item)} if not item_codes: return @@ -34,6 +33,4 @@ def execute(): if not updates: return - frappe.db.auto_commit_on_many_writes = True frappe.db.bulk_update("Job Card", updates) - frappe.db.auto_commit_on_many_writes = False