set qty as per stock uom in entire purchase cycle
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index afccdfa..acb0024 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -17,6 +17,7 @@
self.supplier_name = frappe.db.get_value("Supplier",
self.supplier, "supplier_name")
self.is_item_table_empty()
+ self.set_qty_as_per_stock_uom()
self.validate_stock_or_nonstock_items()
self.validate_warehouse()
@@ -317,3 +318,10 @@
def is_item_table_empty(self):
if not len(self.get(self.fname)):
frappe.throw(_("Item table can not be blank"))
+
+ def set_qty_as_per_stock_uom(self):
+ for d in self.get(self.fname):
+ if d.meta.get_field("stock_qty") and not d.stock_qty:
+ if not d.conversion_factor:
+ frappe.throw(_("Row {0}: Conversion Factor is mandatory"))
+ d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
\ No newline at end of file
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index f9a1d9f..82b396f 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -152,6 +152,7 @@
"min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "",
"conversion_factor": 1.0,
"qty": 1.0,
+ "stock_qty": 1.0,
"price_list_rate": 0.0,
"base_price_list_rate": 0.0,
"rate": 0.0,