mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 14:41:53 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user