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.
This commit is contained in:
Mihir Kandoi
2026-08-01 14:40:14 +05:30
parent 500b9073e7
commit b5cb12c3d7

View File

@@ -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