[Fix] For non stock item, not able to place an order from shopping cart (#12758)
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index c3deaf2..254d7b7 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -65,10 +65,13 @@
from erpnext.selling.doctype.quotation.quotation import _make_sales_order
sales_order = frappe.get_doc(_make_sales_order(quotation.name, ignore_permissions=True))
for item in sales_order.get("items"):
- item.reserved_warehouse = frappe.db.get_value("Item", item.item_code, "website_warehouse") or None
- item_stock = get_qty_in_stock(item.item_code, "website_warehouse")
- if item.qty > item_stock.stock_qty[0][0]:
- throw(_("Only {0} in stock for item {1}").format(item_stock.stock_qty[0][0], item.item_code))
+ item.reserved_warehouse, is_stock_item = frappe.db.get_value("Item",
+ item.item_code, ["website_warehouse", "is_stock_item"]) or None, None
+
+ if is_stock_item:
+ item_stock = get_qty_in_stock(item.item_code, "website_warehouse")
+ if item.qty > item_stock.stock_qty[0][0]:
+ throw(_("Only {0} in stock for item {1}").format(item_stock.stock_qty[0][0], item.item_code))
sales_order.flags.ignore_permissions = True
sales_order.insert()