mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 22:51:49 +00:00
fix(stock): savepoint per-company Material Request creation in reorder (Postgres)
create_material_request loops companies inserting+submitting a Material Request; the except calls mr.log_error (INSERT) with no rollback, raising InFailedSqlTransaction on Postgres in the scheduled reorder job, and the next company runs in the poisoned txn. Savepoint per iteration + rollback(save_point=) before log_error. No-op on MariaDB.
This commit is contained in:
@@ -216,6 +216,7 @@ def create_material_request(material_requests):
|
||||
company_wise_mr = frappe._dict({})
|
||||
for request_type in material_requests:
|
||||
for company in material_requests[request_type]:
|
||||
frappe.db.savepoint("reorder_mr")
|
||||
try:
|
||||
items = material_requests[request_type][company]
|
||||
if not items:
|
||||
@@ -287,6 +288,7 @@ def create_material_request(material_requests):
|
||||
company_wise_mr.setdefault(company, []).append(mr)
|
||||
|
||||
except Exception as exception:
|
||||
frappe.db.rollback(save_point="reorder_mr")
|
||||
exceptions_list.append(exception)
|
||||
mr.log_error("Unable to create material request")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user