fix: allow to select parent warehouse in the website item (backport #37047) (#37173)

fix: allow to select parent warehouse in the website item (#37047)

(cherry picked from commit e6199dc802)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2023-09-20 18:06:30 +05:30
committed by GitHub
parent c5df164e1c
commit 56657b6122
10 changed files with 75 additions and 44 deletions

View File

@@ -25,9 +25,19 @@ def get_context(context):
def get_stock_availability(item_code, warehouse):
stock_qty = frappe.utils.flt(
frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, "actual_qty")
)
from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
if warehouse and frappe.get_cached_value("Warehouse", warehouse, "is_group") == 1:
warehouses = get_child_warehouses(warehouse)
else:
warehouses = [warehouse] if warehouse else []
stock_qty = 0.0
for warehouse in warehouses:
stock_qty += frappe.utils.flt(
frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse}, "actual_qty")
)
return bool(stock_qty)