From cb4b2ec52af675be29d566da7d8c52fddf4eb648 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 10 Jul 2015 17:31:06 +0530 Subject: [PATCH] Fixes in validate baatch function --- erpnext/stock/doctype/stock_entry/stock_entry.py | 4 ++-- .../stock/doctype/stock_ledger_entry/stock_ledger_entry.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index d30e7f2eda..c3597e3b88 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -730,9 +730,9 @@ class StockEntry(StockController): if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]: for item in self.get("items"): if item.batch_no: - expiry_date = getdate(frappe.db.get_value("Batch", item.batch_no, "expiry_date")) + expiry_date = frappe.db.get_value("Batch", item.batch_no, "expiry_date") if expiry_date: - if getdate(self.posting_date) > expiry_date: + if getdate(self.posting_date) > getdate(expiry_date): frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code)) @frappe.whitelist() diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 848a00d554..ff027d7d0b 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -100,9 +100,9 @@ class StockLedgerEntry(Document): def validate_batch(self): if self.batch_no and self.voucher_type != "Stock Entry": - expiry_date = getdate(frappe.db.get_value("Batch", self.batch_no, "expiry_date")) + expiry_date = frappe.db.get_value("Batch", self.batch_no, "expiry_date") if expiry_date: - if getdate(self.posting_date) > expiry_date: + if getdate(self.posting_date) > getdate(expiry_date): frappe.throw(_("Batch {0} of Item {1} has expired.").format(self.batch_no, self.item_code)) def on_doctype_update():