Merge pull request #19386 from rohitwaghchaure/while_making_return_entry_not_able_to_select_null_batch
fix: not able to select the zero qty batch while making the sales ret…
This commit is contained in:
commit
5d0362669d
@ -280,22 +280,31 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
"page_len": page_len
|
"page_len": page_len
|
||||||
}
|
}
|
||||||
|
|
||||||
|
having_clause = "having sum(sle.actual_qty) > 0"
|
||||||
|
if filters.get("is_return"):
|
||||||
|
having_clause = ""
|
||||||
|
|
||||||
if args.get('warehouse'):
|
if args.get('warehouse'):
|
||||||
batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom, concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
|
batch_nos = frappe.db.sql("""select sle.batch_no, round(sum(sle.actual_qty),2), sle.stock_uom,
|
||||||
from `tabStock Ledger Entry` sle
|
concat('MFG-',batch.manufacturing_date), concat('EXP-',batch.expiry_date)
|
||||||
INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
|
from `tabStock Ledger Entry` sle
|
||||||
where
|
INNER JOIN `tabBatch` batch on sle.batch_no = batch.name
|
||||||
batch.disabled = 0
|
where
|
||||||
and sle.item_code = %(item_code)s
|
batch.disabled = 0
|
||||||
and sle.warehouse = %(warehouse)s
|
and sle.item_code = %(item_code)s
|
||||||
and (sle.batch_no like %(txt)s
|
and sle.warehouse = %(warehouse)s
|
||||||
or batch.manufacturing_date like %(txt)s)
|
and (sle.batch_no like %(txt)s
|
||||||
and batch.docstatus < 2
|
or batch.manufacturing_date like %(txt)s)
|
||||||
{0}
|
and batch.docstatus < 2
|
||||||
{match_conditions}
|
{cond}
|
||||||
group by batch_no having sum(sle.actual_qty) > 0
|
{match_conditions}
|
||||||
order by batch.expiry_date, sle.batch_no desc
|
group by batch_no {having_clause}
|
||||||
limit %(start)s, %(page_len)s""".format(cond, match_conditions=get_match_cond(doctype)), args)
|
order by batch.expiry_date, sle.batch_no desc
|
||||||
|
limit %(start)s, %(page_len)s""".format(
|
||||||
|
cond=cond,
|
||||||
|
match_conditions=get_match_cond(doctype),
|
||||||
|
having_clause = having_clause
|
||||||
|
), args)
|
||||||
|
|
||||||
return batch_nos
|
return batch_nos
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1653,6 +1653,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
'item_code': item.item_code,
|
'item_code': item.item_code,
|
||||||
'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(),
|
'posting_date': me.frm.doc.posting_date || frappe.datetime.nowdate(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doc.is_return) {
|
||||||
|
filters["is_return"] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.warehouse) filters["warehouse"] = item.warehouse;
|
if (item.warehouse) filters["warehouse"] = item.warehouse;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user