diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index 0611511ba0edc4cc32d7dbdf4897b3387ac74903..7f233906a6eda18d2cd4952f58d16e2e54cc9a72 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -160,6 +160,7 @@ class DeprecatedBatchNoValuation: & (sle.batch_no.isnotnull()) & (sle.is_cancelled == 0) ) + .for_update() .groupby(sle.batch_no) ) @@ -266,6 +267,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) ) @@ -312,6 +314,7 @@ class DeprecatedBatchNoValuation: .where(timestamp_condition) .orderby(sle.posting_datetime, order=Order.desc) .orderby(sle.creation, order=Order.desc) + .for_update() .limit(1) ) @@ -369,6 +372,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 58e88a8ec2bc6d8df47032de67e2c16c2e60da95..9eb370ecd94275f4d044d6c960c1ac4b24b64fb1 100644 --- a/erpnext/stock/serial_batch_bundle.py +++ b/erpnext/stock/serial_batch_bundle.py @@ -765,6 +765,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation): & (parent.is_cancelled == 0) & (parent.type_of_transaction.isin(["Inward", "Outward"])) ) + .for_update() .groupby(child.batch_no) )