Merge pull request #1881 from anandpdoshi/anand-wip
Fixes to end_of_life conditions
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 626c3fc..2d41d0a 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -149,7 +149,7 @@
@frappe.whitelist()
def get_item_details(item):
res = frappe.db.sql("""select stock_uom, description
- from `tabItem` where (ifnull(end_of_life, "")="" or end_of_life > now())
+ from `tabItem` where (ifnull(end_of_life, "0000-00-00")="0000-00-00" or end_of_life > now())
and name=%s""", item, as_dict=1)
if not res:
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 185fe31..1de9ad2 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -283,7 +283,7 @@
if not end_of_life:
end_of_life = frappe.db.get_value("Item", item_code, "end_of_life")
- if end_of_life and getdate(end_of_life) <= now_datetime().date():
+ if end_of_life and end_of_life!="0000-00-00" and getdate(end_of_life) <= now_datetime().date():
msg = _("Item {0} has reached its end of life on {1}").format(item_code, formatdate(end_of_life))
_msgprint(msg, verbose)
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 252a296..c724497 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -190,7 +190,9 @@
and exists (select name from `tabItem`
where `tabItem`.name = `tabBin`.item_code and
is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and
- (ifnull(end_of_life, '')='' or end_of_life > curdate()))""", as_dict=True)
+ (ifnull(end_of_life, '0000-00-00')='0000-00-00' or end_of_life > curdate()))""",
+ as_dict=True)
+
for bin in bin_list:
#check if re-order is required
item_reorder = frappe.db.get("Item Reorder",