Fixed issues in Expired Batches while making Stock Entry
This commit is contained in:
parent
621d6eac3c
commit
ebb60f5dbc
@ -229,8 +229,9 @@ def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len,
|
|||||||
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
|
}, { "start": start, "page_len": page_len, "txt": ("%%%s%%" % txt) })
|
||||||
|
|
||||||
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
||||||
if not filters.get("posting_date"):
|
cond = ""
|
||||||
filters["posting_date"] = nowdate()
|
if filters.get("posting_date"):
|
||||||
|
cond = "and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)"
|
||||||
|
|
||||||
batch_nos = None
|
batch_nos = None
|
||||||
args = {
|
args = {
|
||||||
@ -251,23 +252,23 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
and sle.warehouse = %(warehouse)s
|
and sle.warehouse = %(warehouse)s
|
||||||
and sle.batch_no like %(txt)s
|
and sle.batch_no like %(txt)s
|
||||||
and batch.docstatus < 2
|
and batch.docstatus < 2
|
||||||
and (ifnull(batch.expiry_date, '')='' or batch.expiry_date >= %(posting_date)s)
|
{0}
|
||||||
{match_conditions}
|
{match_conditions}
|
||||||
group by batch_no having sum(sle.actual_qty) > 0
|
group by batch_no having sum(sle.actual_qty) > 0
|
||||||
order by batch.expiry_date, sle.batch_no desc
|
order by batch.expiry_date, sle.batch_no desc
|
||||||
limit %(start)s, %(page_len)s""".format(match_conditions=get_match_cond(doctype)), args)
|
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
|
||||||
|
|
||||||
if batch_nos:
|
if batch_nos:
|
||||||
return batch_nos
|
return batch_nos
|
||||||
else:
|
else:
|
||||||
return frappe.db.sql("""select name, expiry_date from `tabBatch`
|
return frappe.db.sql("""select name, expiry_date from `tabBatch` batch
|
||||||
where item = %(item_code)s
|
where item = %(item_code)s
|
||||||
and name like %(txt)s
|
and name like %(txt)s
|
||||||
and docstatus < 2
|
and docstatus < 2
|
||||||
and (ifnull(expiry_date, '')='' or expiry_date >= %(posting_date)s)
|
{0}
|
||||||
{match_conditions}
|
{match_conditions}
|
||||||
order by expiry_date, name desc
|
order by expiry_date, name desc
|
||||||
limit %(start)s, %(page_len)s""".format(match_conditions=get_match_cond(doctype)), args)
|
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args, debug=1)
|
||||||
|
|
||||||
def get_account_list(doctype, txt, searchfield, start, page_len, filters):
|
def get_account_list(doctype, txt, searchfield, start, page_len, filters):
|
||||||
filter_list = []
|
filter_list = []
|
||||||
|
@ -71,7 +71,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
} else {
|
} else {
|
||||||
filters = {
|
filters = {
|
||||||
'item_code': item.item_code,
|
'item_code': item.item_code,
|
||||||
'posting_date': me.frm.doc.posting_date,
|
'posting_date': me.frm.doc.posting_date || nowdate(),
|
||||||
}
|
}
|
||||||
if(item.warehouse) filters["warehouse"] = item.warehouse
|
if(item.warehouse) filters["warehouse"] = item.warehouse
|
||||||
|
|
||||||
|
@ -411,14 +411,21 @@ cur_frm.fields_dict['items'].grid.get_field('batch_no').get_query = function(doc
|
|||||||
var item = locals[cdt][cdn];
|
var item = locals[cdt][cdn];
|
||||||
if(!item.item_code) {
|
if(!item.item_code) {
|
||||||
frappe.throw(__("Please enter Item Code to get batch no"));
|
frappe.throw(__("Please enter Item Code to get batch no"));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
if (in_list(["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"], doc.purpose)) {
|
||||||
var filters = {
|
var filters = {
|
||||||
'item_code': item.item_code,
|
'item_code': item.item_code,
|
||||||
'posting_date': me.frm.doc.posting_date,
|
'posting_date': me.frm.doc.posting_date || nowdate()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var filters = {
|
||||||
|
'item_code': item.item_code
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item.s_warehouse) filters["warehouse"] = item.s_warehouse
|
|
||||||
|
|
||||||
|
if(item.s_warehouse) filters["warehouse"] = item.s_warehouse
|
||||||
return {
|
return {
|
||||||
query : "erpnext.controllers.queries.get_batch_no",
|
query : "erpnext.controllers.queries.get_batch_no",
|
||||||
filters: filters
|
filters: filters
|
||||||
|
@ -727,7 +727,7 @@ class StockEntry(StockController):
|
|||||||
frappe.MappingMismatchError)
|
frappe.MappingMismatchError)
|
||||||
|
|
||||||
def validate_batch(self):
|
def validate_batch(self):
|
||||||
if self.purpose == "Material Transfer for Manufacture":
|
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")):
|
if getdate(self.posting_date) > getdate(frappe.db.get_value("Batch", item.batch_no, "expiry_date")):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user