[validation] fixes in item
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index b579195..0fc7875 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -194,9 +194,7 @@
if self.doc.name:
self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name')
-
- self.validate_is_stock_item()
-
+
def check_non_asset_warehouse(self):
if self.doc.is_asset_item == "Yes":
existing_qty = sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
@@ -216,14 +214,6 @@
}
return ret
- def validate_is_stock_item(self):
- if not self.doc.fields.get("__islocal"):
- if webnotes.conn.get_value("Item", self.doc.name, "is_stock_item")=="Yes" and \
- ((not self.doc.is_stock_item) or self.doc.is_stock_item == "No"):
- if self.check_if_sle_exists() == "exists":
- webnotes.msgprint(self.meta.get_label("is_stock_item") + ": "
- + _("""Cannot change to Yes. Reason: Stock Ledger Entries exist for""")
- + """ "%s" """ % self.doc.name, raise_exception=True)
def check_if_sle_exists(self):
sle = sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
@@ -245,13 +235,14 @@
get_slideshow(self)
def cant_change(self):
- vals = webnotes.conn.get_value("Item", self.doc.name,
- ["has_serial_no", "is_stock_item", "valuation_method"], as_dict=True)
+ if not self.doc.fields.get("__islocal"):
+ vals = webnotes.conn.get_value("Item", self.doc.name,
+ ["has_serial_no", "is_stock_item", "valuation_method"], as_dict=True)
- if (vals.has_serial_no != self.doc.has_serial_no or
- vals.is_stock_item != self.doc.is_stock_item or
- vals.valuation_method != self.doc.valuation_method):
- if self.check_if_sle_exists():
- webnotes.msgprint(_("As there are existing stock transactions for this item, \
- you can not change the values of 'Has Serial No', 'Is Stock Item' and \
- 'Valuation Method'"), raise_exception=1)
\ No newline at end of file
+ if vals and (vals.has_serial_no != self.doc.has_serial_no or
+ vals.is_stock_item != self.doc.is_stock_item or
+ vals.valuation_method != self.doc.valuation_method):
+ if self.check_if_sle_exists():
+ webnotes.msgprint(_("As there are existing stock transactions for this \
+ item, you can not change the values of 'Has Serial No', \
+ 'Is Stock Item' and 'Valuation Method'"), raise_exception=1)
\ No newline at end of file