Negative stock allowed for perpetual inventory. Blocked in specific case
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 66d5792..cf57658 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -277,6 +277,9 @@
"qty": -1 * required_qty,
"serial_no": rm.serial_no
})
+ if not item_rate:
+ from erpnext.controllers.stock_controller import get_valuation_rate
+ item_rate = get_valuation_rate(bom_item.item_code, self.supplier_warehouse)
rm.rate = item_rate or bom_item.rate
else:
rm.rate = bom_item.rate
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index ad553d8..a72a3d0 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -30,7 +30,7 @@
def get_gl_entries(self, warehouse_account=None, default_expense_account=None,
default_cost_center=None, allow_negative_stock=False):
- block_negative_stock(allow_negative_stock)
+ # block_negative_stock(allow_negative_stock)
if not warehouse_account:
warehouse_account = get_warehouse_account()
@@ -319,4 +319,7 @@
if not valuation_rate:
valuation_rate = frappe.db.get_value("Item Price", {"item_code": item_code, "buying": 1}, "price_list_rate")
+ if not valuation_rate:
+ frappe.throw(_("Purchase rate for item: {0} not found, which is required to book accounting entry. Please mention item price against a buying price list.").format(item_code))
+
return valuation_rate