diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index 7345191d785e9cd4b3a7c08357b073ed840798f9..062f63c0c5eba940e4c0e939068d6ddbae4a4665 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -139,6 +139,7 @@ class DeprecatedBatchNoValuation: & (sle.batch_no.isnotnull()) & (sle.is_cancelled == 0) ) + .for_update() .groupby(sle.batch_no) ) @@ -231,6 +232,7 @@ class DeprecatedBatchNoValuation: & (sle.is_cancelled == 0) & (sle.batch_no.isin(self.non_batchwise_valuation_batches)) ) + .for_update() .where(timestamp_condition) .groupby(sle.batch_no) ) @@ -277,6 +279,7 @@ class DeprecatedBatchNoValuation: .where(timestamp_condition) .orderby(sle.posting_datetime, order=Order.desc) .orderby(sle.creation, order=Order.desc) + .for_update() .limit(1) ) @@ -324,6 +327,7 @@ class DeprecatedBatchNoValuation: & (bundle.type_of_transaction.isin(["Inward", "Outward"])) & (bundle_child.batch_no.isin(self.non_batchwise_valuation_batches)) ) + .for_update() .where(timestamp_condition) .groupby(bundle_child.batch_no) ) diff --git a/erpnext/stock/serial_batch_bundle.py b/erpnext/stock/serial_batch_bundle.py index 7259921ab7112d51348d86bec8119e9d6019e40e..d803f84de30edfb615aaf71e9b40f8d020eac68d 100644 --- a/erpnext/stock/serial_batch_bundle.py +++ b/erpnext/stock/serial_batch_bundle.py @@ -672,6 +672,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation): & (parent.is_cancelled == 0) & (parent.type_of_transaction.isin(["Inward", "Outward"])) ) + .for_update() .groupby(child.batch_no) )