Merge pull request #3621 from neilLasrado/batch
Validation added to prevent adding items with expired batch numbers t…
This commit is contained in:
commit
97bb6bbaf4
@ -730,8 +730,10 @@ class StockEntry(StockController):
|
|||||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
|
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.batch_no:
|
if item.batch_no:
|
||||||
if getdate(self.posting_date) > getdate(frappe.db.get_value("Batch", item.batch_no, "expiry_date")):
|
expiry_date = frappe.db.get_value("Batch", item.batch_no, "expiry_date")
|
||||||
frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
|
if 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()
|
@frappe.whitelist()
|
||||||
def get_party_details(ref_dt, ref_dn):
|
def get_party_details(ref_dt, ref_dn):
|
||||||
|
@ -18,6 +18,7 @@ class StockLedgerEntry(Document):
|
|||||||
from erpnext.stock.utils import validate_warehouse_company
|
from erpnext.stock.utils import validate_warehouse_company
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_item()
|
self.validate_item()
|
||||||
|
self.validate_batch()
|
||||||
validate_warehouse_company(self.warehouse, self.company)
|
validate_warehouse_company(self.warehouse, self.company)
|
||||||
self.scrub_posting_time()
|
self.scrub_posting_time()
|
||||||
|
|
||||||
@ -97,6 +98,13 @@ class StockLedgerEntry(Document):
|
|||||||
if not self.posting_time or self.posting_time == '00:0':
|
if not self.posting_time or self.posting_time == '00:0':
|
||||||
self.posting_time = '00:00'
|
self.posting_time = '00:00'
|
||||||
|
|
||||||
|
def validate_batch(self):
|
||||||
|
if self.batch_no and self.voucher_type != "Stock Entry":
|
||||||
|
expiry_date = frappe.db.get_value("Batch", self.batch_no, "expiry_date")
|
||||||
|
if 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():
|
def on_doctype_update():
|
||||||
if not frappe.db.sql("""show index from `tabStock Ledger Entry`
|
if not frappe.db.sql("""show index from `tabStock Ledger Entry`
|
||||||
where Key_name="posting_sort_index" """):
|
where Key_name="posting_sort_index" """):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user