test(manufacturing): savepoint duplicate Routing insert in create_routing (Postgres)

create_routing inserts a Routing and, on DuplicateEntryError, re-fetches and updates. On Postgres the failed insert aborts the transaction so the get_doc/save in the except raises InFailedSqlTransaction; MariaDB recovers. Savepoint + rollback before the fallback path.
This commit is contained in:
Mihir Kandoi
2026-06-29 20:39:25 +05:30
parent 2b966b69ce
commit 0978d0304f

View File

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