mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-12 14:11:46 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user