fix: prevent concurrency issues

(cherry picked from commit a186b1266d)
This commit is contained in:
Rohit Waghchaure
2025-07-27 18:45:23 +05:30
committed by Mergify
parent 442fede0fe
commit ad75754ca6
2 changed files with 5 additions and 0 deletions

View File

@@ -141,6 +141,7 @@ class DeprecatedBatchNoValuation:
& (sle.batch_no.isnotnull())
& (sle.is_cancelled == 0)
)
.for_update()
.groupby(sle.batch_no)
)
@@ -232,6 +233,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)
)
@@ -278,6 +280,7 @@ class DeprecatedBatchNoValuation:
.where(timestamp_condition)
.orderby(sle.posting_datetime, order=Order.desc)
.orderby(sle.creation, order=Order.desc)
.for_update()
.limit(1)
)
@@ -330,6 +333,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)
)

View File

@@ -723,6 +723,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation):
& (parent.is_cancelled == 0)
& (parent.type_of_transaction.isin(["Inward", "Outward"]))
)
.for_update()
.groupby(child.batch_no)
)