-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: consider reserved stock while cancelling a stock transaction (ba…
…ckport #37754) (#37906) * fix: consider reserved serial nos while cancelling a stock transaction (cherry picked from commit d9e2843) * fix: consider reserved batches while cancelling a stock transaction (cherry picked from commit e1a87a8) * feat: add field `reserved_stock` in Bin (cherry picked from commit 98d6cdd) * feat: maintain `Reserved Stock` in Bin (cherry picked from commit f52916a) * fix: consider reserved stock while cancelling a stock transaction (cherry picked from commit 73b65ac) * fix(test): `test_stock_reservation_against_sales_order` (cherry picked from commit 1024223) * chore: patch to set reserved stock in Bin (cherry picked from commit 1f88b1e) * fix: qty based check for stock reservation of serial-batch items based on qty (cherry picked from commit 9231706) * test: add test case for stock stock reservation (cherry picked from commit 54b323e) --------- Co-authored-by: s-aga-r <[email protected]>
- Loading branch information
1 parent
5171e32
commit e0b0b6b
Showing
8 changed files
with
279 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import frappe | ||
from frappe.query_builder.functions import Sum | ||
|
||
|
||
def execute(): | ||
sre = frappe.qb.DocType("Stock Reservation Entry") | ||
query = ( | ||
frappe.qb.from_(sre) | ||
.select( | ||
sre.item_code, | ||
sre.warehouse, | ||
Sum(sre.reserved_qty - sre.delivered_qty).as_("reserved_stock"), | ||
) | ||
.where((sre.docstatus == 1) & (sre.status.notin(["Delivered", "Cancelled"]))) | ||
.groupby(sre.item_code, sre.warehouse) | ||
) | ||
|
||
for d in query.run(as_dict=True): | ||
frappe.db.set_value( | ||
"Bin", | ||
{"item_code": d.item_code, "warehouse": d.warehouse}, | ||
"reserved_stock", | ||
d.reserved_stock, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.