From e673a664ac689d8780eca6de552ad554272e9347 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Jul 2014 18:12:02 +0530 Subject: [PATCH] Fixes to end_of_life conditions --- .../doctype/production_order/production_order.py | 2 +- erpnext/stock/doctype/item/item.py | 2 +- erpnext/stock/utils.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 626c3fcbe14..2d41d0a6a4a 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -149,7 +149,7 @@ class ProductionOrder(Document): @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 185fe314c5f..1de9ad29bef 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -283,7 +283,7 @@ def validate_end_of_life(item_code, end_of_life=None, verbose=1): 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 252a296d8b5..c724497f11b 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -190,7 +190,9 @@ def reorder_item(): 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",