Stocking out items with expired batches (#14249)
* Add dropdown in Stock Entry to get expired batch items * Fetch all the items with expired batches * Add the fetched item details to stock entry details * Modify as per the review comments
This commit is contained in:
parent
05152dad0b
commit
47335e5e60
@ -156,6 +156,29 @@ frappe.ui.form.on('Stock Entry', {
|
||||
})
|
||||
}, __("Get items from"));
|
||||
}
|
||||
if (frm.doc.docstatus===0 && frm.doc.purpose == "Material Issue") {
|
||||
frm.add_custom_button(__('Expired Batches'), function() {
|
||||
frappe.call({
|
||||
method: "erpnext.stock.doctype.stock_entry.stock_entry.get_expired_batch_items",
|
||||
callback: function(r) {
|
||||
if (!r.exc && r.message) {
|
||||
frm.set_value("items", []);
|
||||
r.message.forEach(function(element) {
|
||||
let d = frm.add_child("items");
|
||||
d.item_code = element.item;
|
||||
d.s_warehouse = element.warehouse;
|
||||
d.qty = element.qty;
|
||||
d.uom = element.stock_uom;
|
||||
d.conversion_factor = 1;
|
||||
d.batch_no = element.batch_no;
|
||||
d.transfer_qty = element.qty;
|
||||
frm.refresh_fields();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, __("Get items from"));
|
||||
}
|
||||
|
||||
if (frm.doc.company) {
|
||||
frm.trigger("toggle_display_account_head");
|
||||
|
@ -1165,6 +1165,15 @@ def get_uom_details(item_code, uom, qty):
|
||||
}
|
||||
return ret
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_expired_batch_items():
|
||||
return frappe.db.sql("""select b.item, sum(sle.actual_qty) as qty, sle.batch_no, sle.warehouse, sle.stock_uom\
|
||||
from `tabBatch` b, `tabStock Ledger Entry` sle
|
||||
where b.expiry_date <= %s
|
||||
and b.expiry_date is not NULL
|
||||
and b.batch_id = sle.batch_no
|
||||
group by sle.warehouse, sle.item_code, sle.batch_no""",(nowdate()), as_dict=1)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_warehouse_details(args):
|
||||
if isinstance(args, string_types):
|
||||
|
Loading…
Reference in New Issue
Block a user