fix(buying): savepoint Subcontracting Order submit in make_subcontracting_order (Postgres)

target_doc.submit() is wrapped in except Exception whose handler calls add_comment (a Comment insert). On Postgres a failed submit poisons the transaction so the add_comment insert raises InFailedSqlTransaction; MariaDB logs the comment. Savepoint + rollback before add_comment. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 20:39:23 +05:30
parent 747374e767
commit b6165844ed

View File

@@ -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") + "<br><br>" + str(e))
if notify: