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():