diff --git a/erpnext/buying/doctype/purchase_order/mapper.py b/erpnext/buying/doctype/purchase_order/mapper.py
index 468ab3e2e5d..1aa3d2c6eac 100644
--- a/erpnext/buying/doctype/purchase_order/mapper.py
+++ b/erpnext/buying/doctype/purchase_order/mapper.py
@@ -232,9 +232,11 @@ def make_subcontracting_order(
target_doc.save()
if submit and frappe.has_permission(target_doc.doctype, "submit", target_doc):
+ frappe.db.savepoint("submit_subcontracting_order")
try:
target_doc.submit()
except Exception as e:
+ frappe.db.rollback(save_point="submit_subcontracting_order")
target_doc.add_comment("Comment", _("Submit Action Failed") + "
" + str(e))
if notify:
diff --git a/erpnext/manufacturing/doctype/routing/test_routing.py b/erpnext/manufacturing/doctype/routing/test_routing.py
index 4575c1d1d57..1cec3b657b4 100644
--- a/erpnext/manufacturing/doctype/routing/test_routing.py
+++ b/erpnext/manufacturing/doctype/routing/test_routing.py
@@ -102,9 +102,11 @@ def create_routing(**args):
doc.update(args)
if not args.do_not_save:
+ frappe.db.savepoint("create_routing")
try:
doc.insert()
except frappe.DuplicateEntryError:
+ frappe.db.rollback(save_point="create_routing")
doc = frappe.get_doc("Routing", args.routing_name)
doc.delete_key("operations")
for operation in args.operations:
diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
index 4be57de747a..b9bb3d931da 100644
--- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
+++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
@@ -779,6 +779,7 @@ def make_reposting_for_accounting_ledgers(transactions, company, repost_doc):
if reposting_map.get((voucher_type, voucher_no)):
continue
+ frappe.db.savepoint("repost_accounting_ledger")
try:
new_repost_doc = frappe.new_doc("Repost Item Valuation")
new_repost_doc.company = company
@@ -789,7 +790,7 @@ def make_reposting_for_accounting_ledgers(transactions, company, repost_doc):
new_repost_doc.flags.ignore_permissions = True
new_repost_doc.submit()
except Exception:
- pass
+ frappe.db.rollback(save_point="repost_accounting_ledger")
def get_existing_reposting_only_gl_entries(reposting_reference):
diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/mapper.py b/erpnext/subcontracting/doctype/subcontracting_receipt/mapper.py
index 4927d6723c0..bf5fbd5775a 100644
--- a/erpnext/subcontracting/doctype/subcontracting_receipt/mapper.py
+++ b/erpnext/subcontracting/doctype/subcontracting_receipt/mapper.py
@@ -125,9 +125,11 @@ def make_purchase_receipt(
target_doc.save()
if submit and frappe.has_permission(target_doc.doctype, "submit", target_doc):
+ frappe.db.savepoint("submit_subcontracting_receipt")
try:
target_doc.submit()
except Exception as e:
+ frappe.db.rollback(save_point="submit_subcontracting_receipt")
target_doc.add_comment("Comment", _("Submit Action Failed") + "
" + str(e))
if notify: