[Fix] For non stock item, not able to place an order from shopping cart (#12758)

This commit is contained in:
rohitwaghchaure 2018-02-05 12:25:02 +05:30 committed by Nabin Hait
parent a4c40e0fd6
commit 0f5c18ca81

View File

@ -65,10 +65,13 @@ def place_order():
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()