fix(postgres): savepoint bank-account creation during company setup

create_bank_account() inserts a bank Account and swallows DuplicateEntryError
('bank account same as a CoA entry'). On Postgres the failed insert aborts the
transaction, so the rest of company setup ran against a poisoned transaction.
Take a savepoint and roll back to it in the handler. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-21 15:48:37 +05:30
parent 0e25a77a62
commit bac4f1de52

View File

@@ -567,6 +567,7 @@ def create_bank_account(args, demo=False):
}
)
try:
frappe.db.savepoint("create_bank_account")
doc = bank_account.insert()
if args.get("set_default"):
@@ -583,6 +584,7 @@ def create_bank_account(args, demo=False):
except RootNotEditable:
frappe.throw(frappe._("Bank account cannot be named as {0}").format(args.get("bank_account")))
except frappe.DuplicateEntryError:
frappe.db.rollback(save_point="create_bank_account") # preserve transaction in postgres
# bank account same as a CoA entry
pass