From 767cf994353373e3e04ee4e2deeb5e0c8446795c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 21 Jul 2016 18:46:01 +0530 Subject: [PATCH] Update opening stock on creation if item, only if it is non-serialized and does maintain batch --- erpnext/stock/doctype/item/item.json | 7 ++++--- erpnext/stock/doctype/item/item.py | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 2ab40c5762..e2aa274d4b 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 de5d54598c..cedfb24d7a 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -118,6 +118,9 @@ class Item(WebsiteGenerator): 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"))