Update opening stock on creation if item, only if it is non-serialized and does maintain batch
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 2ab40c5..e2aa274 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -11,6 +11,7 @@
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
+ "editable_grid": 1,
"fields": [
{
"allow_on_submit": 0,
@@ -305,7 +306,7 @@
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
- "depends_on": "eval:(doc.__islocal&&doc.is_stock_item)",
+ "depends_on": "eval:(doc.__islocal&&doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no)",
"fieldname": "opening_stock",
"fieldtype": "Int",
"hidden": 0,
@@ -331,7 +332,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "depends_on": "eval:(doc.__islocal && doc.is_stock_item && doc.opening_stock)",
+ "depends_on": "eval:(doc.__islocal && doc.is_stock_item && !doc.has_serial_no && !doc.has_batch_no && doc.opening_stock)",
"fieldname": "valuation_rate",
"fieldtype": "Currency",
"hidden": 0,
@@ -2307,7 +2308,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
- "modified": "2016-07-06 17:00:45.561349",
+ "modified": "2016-07-21 18:44:10.230372",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index de5d545..cedfb24 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -118,6 +118,9 @@
def set_opening_stock(self):
'''set opening stock'''
+ if not self.is_stock_item or self.has_serial_no or self.has_batch_no:
+ return
+
if not self.valuation_rate:
frappe.throw(_("Valuation Rate is mandatory if Opening Stock entered"))