refactor: Add exception handling in background job within BOM Update Tool
This commit is contained in:
parent
700e65959a
commit
f57725f8fa
@ -94,20 +94,31 @@ def update_latest_price_in_all_boms():
|
|||||||
update_cost()
|
update_cost()
|
||||||
|
|
||||||
def replace_bom(args):
|
def replace_bom(args):
|
||||||
frappe.db.auto_commit_on_many_writes = 1
|
try:
|
||||||
args = frappe._dict(args)
|
frappe.db.auto_commit_on_many_writes = 1
|
||||||
|
args = frappe._dict(args)
|
||||||
doc = frappe.get_doc("BOM Update Tool")
|
doc = frappe.get_doc("BOM Update Tool")
|
||||||
doc.current_bom = args.current_bom
|
doc.current_bom = args.current_bom
|
||||||
doc.new_bom = args.new_bom
|
doc.new_bom = args.new_bom
|
||||||
doc.replace_bom()
|
doc.replace_bom()
|
||||||
|
except Exception:
|
||||||
frappe.db.auto_commit_on_many_writes = 0
|
frappe.log_error(
|
||||||
|
msg=frappe.get_traceback(),
|
||||||
|
title=_("BOM Update Tool Error")
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
frappe.db.auto_commit_on_many_writes = 0
|
||||||
|
|
||||||
def update_cost():
|
def update_cost():
|
||||||
frappe.db.auto_commit_on_many_writes = 1
|
try:
|
||||||
bom_list = get_boms_in_bottom_up_order()
|
frappe.db.auto_commit_on_many_writes = 1
|
||||||
for bom in bom_list:
|
bom_list = get_boms_in_bottom_up_order()
|
||||||
frappe.get_doc("BOM", bom).update_cost(update_parent=False, from_child_bom=True)
|
for bom in bom_list:
|
||||||
|
frappe.get_doc("BOM", bom).update_cost(update_parent=False, from_child_bom=True)
|
||||||
frappe.db.auto_commit_on_many_writes = 0
|
except Exception:
|
||||||
|
frappe.log_error(
|
||||||
|
msg=frappe.get_traceback(),
|
||||||
|
title=_("BOM Update Tool Error")
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
frappe.db.auto_commit_on_many_writes = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user