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

@@ -104,6 +104,8 @@ def get_attributes_and_values(item_code):
@frappe.whitelist(allow_guest=True)
def get_next_attribute_and_values(item_code, selected_attributes):
from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
"""Find the count of Items that match the selected attributes.
Also, find the attribute values that are not applicable for further searching.
If less than equal to 10 items are found, return item_codes of those items.
@@ -168,7 +170,7 @@ def get_next_attribute_and_values(item_code, selected_attributes):
product_info = None
product_id = ""
website_warehouse = ""
warehouse = ""
if exact_match or filtered_items:
if exact_match and len(exact_match) == 1:
product_id = exact_match[0]
@@ -176,16 +178,19 @@ def get_next_attribute_and_values(item_code, selected_attributes):
product_id = list(filtered_items)[0]
if product_id:
website_warehouse = frappe.get_cached_value(
warehouse = frappe.get_cached_value(
"Website Item", {"item_code": product_id}, "website_warehouse"
)
available_qty = 0.0
if website_warehouse:
available_qty = flt(
frappe.db.get_value(
"Bin", {"item_code": product_id, "warehouse": website_warehouse}, "actual_qty"
)
if warehouse and frappe.get_cached_value("Warehouse", warehouse, "is_group") == 1:
warehouses = get_child_warehouses(warehouse)
else:
warehouses = [warehouse] if warehouse else []
for warehouse in warehouses:
available_qty += flt(
frappe.db.get_value("Bin", {"item_code": product_id, "warehouse": warehouse}, "actual_qty")
)
return {