mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 15:11:52 +00:00
Merge pull request #56622 from mihir-kandoi/pg-savepoint-txn-abort
fix: savepoint catch-and-continue DB writes to survive Postgres txn-abort (InFailedSqlTransaction)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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") + "<br><br>" + str(e))
|
||||
|
||||
if notify:
|
||||
|
||||
Reference in New Issue
Block a user