Merge pull request #48809 from frappe/mergify/bp/version-15-hotfix/pr-48787

fix: concurrency issues (backport #48787)
This commit is contained in:
rohitwaghchaure
2025-07-28 17:55:49 +05:30
committed by GitHub
2 changed files with 5 additions and 0 deletions

View File

@@ -141,6 +141,7 @@ class DeprecatedBatchNoValuation:
& (sle.batch_no.isnotnull()) & (sle.batch_no.isnotnull())
& (sle.is_cancelled == 0) & (sle.is_cancelled == 0)
) )
.for_update()
.groupby(sle.batch_no) .groupby(sle.batch_no)
) )
@@ -232,6 +233,7 @@ class DeprecatedBatchNoValuation:
& (sle.is_cancelled == 0) & (sle.is_cancelled == 0)
& (sle.batch_no.isin(self.non_batchwise_valuation_batches)) & (sle.batch_no.isin(self.non_batchwise_valuation_batches))
) )
.for_update()
.where(timestamp_condition) .where(timestamp_condition)
.groupby(sle.batch_no) .groupby(sle.batch_no)
) )
@@ -278,6 +280,7 @@ class DeprecatedBatchNoValuation:
.where(timestamp_condition) .where(timestamp_condition)
.orderby(sle.posting_datetime, order=Order.desc) .orderby(sle.posting_datetime, order=Order.desc)
.orderby(sle.creation, order=Order.desc) .orderby(sle.creation, order=Order.desc)
.for_update()
.limit(1) .limit(1)
) )
@@ -330,6 +333,7 @@ class DeprecatedBatchNoValuation:
& (bundle.type_of_transaction.isin(["Inward", "Outward"])) & (bundle.type_of_transaction.isin(["Inward", "Outward"]))
& (bundle_child.batch_no.isin(self.non_batchwise_valuation_batches)) & (bundle_child.batch_no.isin(self.non_batchwise_valuation_batches))
) )
.for_update()
.where(timestamp_condition) .where(timestamp_condition)
.groupby(bundle_child.batch_no) .groupby(bundle_child.batch_no)
) )

View File

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