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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user