Allow Disabling Batch and edit Validations (#15076)
This commit is contained in:
parent
614959d5f8
commit
59e4c32e9f
@ -282,7 +282,8 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||
from `tabStock Ledger Entry` sle
|
||||
INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
|
||||
where
|
||||
sle.item_code = %(item_code)s
|
||||
batch.disabled = 0
|
||||
and sle.item_code = %(item_code)s
|
||||
and sle.warehouse = %(warehouse)s
|
||||
and (sle.batch_no like %(txt)s
|
||||
or batch.manufacturing_date like %(txt)s)
|
||||
@ -297,7 +298,8 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||
return batch_nos
|
||||
else:
|
||||
return frappe.db.sql("""select name, concat('MFG-', manufacturing_date), concat('EXP-',expiry_date) from `tabBatch` batch
|
||||
where item = %(item_code)s
|
||||
where batch.disabled = 0
|
||||
and item = %(item_code)s
|
||||
and (name like %(txt)s
|
||||
or manufacturing_date like %(txt)s)
|
||||
and docstatus < 2
|
||||
@ -425,7 +427,8 @@ def get_doctype_wise_filters(filters):
|
||||
@frappe.whitelist()
|
||||
def get_batch_numbers(doctype, txt, searchfield, start, page_len, filters):
|
||||
query = """select batch_id from `tabBatch`
|
||||
where (expiry_date >= CURDATE() or expiry_date IS NULL)
|
||||
where disabled = 0
|
||||
and (expiry_date >= CURDATE() or expiry_date IS NULL)
|
||||
and name like '{txt}'""".format(txt = frappe.db.escape('%{0}%'.format(txt)))
|
||||
|
||||
if filters and filters.get('item'):
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1027,14 +1027,19 @@ class StockEntry(StockController):
|
||||
frappe.MappingMismatchError)
|
||||
|
||||
def validate_batch(self):
|
||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
|
||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract", "Material Issue"]:
|
||||
for item in self.get("items"):
|
||||
if item.batch_no:
|
||||
expiry_date = frappe.db.get_value("Batch", item.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(item.batch_no, item.item_code))
|
||||
disabled = frappe.db.get_value("Batch", item.batch_no, "disabled")
|
||||
if disabled == 0:
|
||||
expiry_date = frappe.db.get_value("Batch", item.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(item.batch_no, item.item_code))
|
||||
else:
|
||||
frappe.throw(_("Batch {0} of Item {1} is disabled.")
|
||||
.format(item.batch_no, item.item_code))
|
||||
|
||||
def update_purchase_order_supplied_items(self):
|
||||
#Get PO Supplied Items Details
|
||||
|
Loading…
x
Reference in New Issue
Block a user