mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-14 17:33:09 +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():
|
def execute():
|
||||||
job_cards = frappe.get_all(
|
job_cards = frappe.get_all(
|
||||||
"Job Card",
|
"Job Card",
|
||||||
filters={"stock_uom": ("in", ["", None])},
|
filters={"stock_uom": ("is", "not set")},
|
||||||
fields=["name", "finished_good", "production_item"],
|
fields=["name", "finished_good", "production_item"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if not job_cards:
|
if not job_cards:
|
||||||
return
|
return
|
||||||
|
|
||||||
item_codes = {row.finished_good or row.production_item for row in job_cards}
|
item_codes = {code for row in job_cards if (code := row.finished_good or row.production_item)}
|
||||||
item_codes.discard(None)
|
|
||||||
if not item_codes:
|
if not item_codes:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -34,6 +33,4 @@ def execute():
|
|||||||
if not updates:
|
if not updates:
|
||||||
return
|
return
|
||||||
|
|
||||||
frappe.db.auto_commit_on_many_writes = True
|
|
||||||
frappe.db.bulk_update("Job Card", updates)
|
frappe.db.bulk_update("Job Card", updates)
|
||||||
frappe.db.auto_commit_on_many_writes = False
|
|
||||||
|
|||||||
Reference in New Issue
Block a user