mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-16 10:20:31 +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({})
|
company_wise_mr = frappe._dict({})
|
||||||
for request_type in material_requests:
|
for request_type in material_requests:
|
||||||
for company in material_requests[request_type]:
|
for company in material_requests[request_type]:
|
||||||
|
frappe.db.savepoint("reorder_mr")
|
||||||
try:
|
try:
|
||||||
items = material_requests[request_type][company]
|
items = material_requests[request_type][company]
|
||||||
if not items:
|
if not items:
|
||||||
@@ -287,6 +288,7 @@ def create_material_request(material_requests):
|
|||||||
company_wise_mr.setdefault(company, []).append(mr)
|
company_wise_mr.setdefault(company, []).append(mr)
|
||||||
|
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
|
frappe.db.rollback(save_point="reorder_mr")
|
||||||
exceptions_list.append(exception)
|
exceptions_list.append(exception)
|
||||||
mr.log_error("Unable to create material request")
|
mr.log_error("Unable to create material request")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user