From 864fe50b243fefbc5e023b017119d136957e44d2 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 29 Jun 2026 20:39:23 +0530 Subject: [PATCH] fix(subcontracting): savepoint Purchase Receipt submit in make_purchase_receipt (Postgres) Same submit()/add_comment-in-except shape as the PO->SCO mapper: on Postgres a failed submit aborts the transaction so the follow-on Comment insert raises InFailedSqlTransaction; MariaDB continues. Savepoint + rollback before add_comment. No-op on MariaDB. --- erpnext/subcontracting/doctype/subcontracting_receipt/mapper.py | 2 ++ 1 file changed, 2 insertions(+) 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: