update get_batch_no query to sort batch with expiry date
small fix to avoid error msg if item_code not selected and batch_no is entered
This commit is contained in:
parent
4944fb33ce
commit
feff40a930
@ -232,7 +232,9 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
|
|
||||||
if filters.has_key('warehouse'):
|
if filters.has_key('warehouse'):
|
||||||
return frappe.db.sql("""select batch_no from `tabStock Ledger Entry` sle
|
return frappe.db.sql("""select batch_no, round(sum(actual_qty),2), stock_uom, expiry_date from `tabStock Ledger Entry` sle
|
||||||
|
INNER JOIN `tabBatch`
|
||||||
|
on sle.batch_no = `tabBatch`.batch_id
|
||||||
where item_code = '%(item_code)s'
|
where item_code = '%(item_code)s'
|
||||||
and warehouse = '%(warehouse)s'
|
and warehouse = '%(warehouse)s'
|
||||||
and batch_no like '%(txt)s'
|
and batch_no like '%(txt)s'
|
||||||
@ -242,7 +244,7 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
and docstatus != 2)
|
and docstatus != 2)
|
||||||
%(mcond)s
|
%(mcond)s
|
||||||
group by batch_no having sum(actual_qty) > 0
|
group by batch_no having sum(actual_qty) > 0
|
||||||
order by batch_no desc
|
order by expiry_date,batch_no desc
|
||||||
limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'],
|
limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'],
|
||||||
'warehouse': filters['warehouse'], 'posting_date': filters['posting_date'],
|
'warehouse': filters['warehouse'], 'posting_date': filters['posting_date'],
|
||||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype),
|
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype),
|
||||||
|
@ -481,16 +481,18 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
batch_no: function(doc, cdt, cdn) {
|
batch_no: function(doc, cdt, cdn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var item = frappe.get_doc(cdt, cdn);
|
var item = frappe.get_doc(cdt, cdn);
|
||||||
return this.frm.call({
|
if(item.item_code) {
|
||||||
method: "erpnext.stock.get_item_details.get_batch_qty",
|
return this.frm.call({
|
||||||
child: item,
|
method: "erpnext.stock.get_item_details.get_batch_qty",
|
||||||
args: {
|
child: item,
|
||||||
"batch_no": item.batch_no,
|
args: {
|
||||||
"warehouse": item.warehouse,
|
"batch_no": item.batch_no,
|
||||||
"item_code": item.item_code
|
"warehouse": item.warehouse,
|
||||||
},
|
"item_code": item.item_code
|
||||||
"fieldname": "actual_batch_qty"
|
},
|
||||||
});
|
"fieldname": "actual_batch_qty"
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set_dynamic_labels: function() {
|
set_dynamic_labels: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user