[fix] Batch selected in the sales transaction for non batch item (#11713)
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 6a148e2..c8b48a5 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -355,7 +355,7 @@
*/
set_batch_number: function(cdt, cdn) {
const doc = frappe.get_doc(cdt, cdn);
- if(doc) {
+ if (doc && doc.has_batch_no) {
this._set_batch_number(doc);
}
},
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index 8d72ac3..6dac647 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -149,7 +149,7 @@
'select batch_id, sum(actual_qty) as qty from `tabBatch` join `tabStock Ledger Entry` '
'on `tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no '
'where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s '
- 'and `tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL '
+ 'and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL)'
'group by batch_id '
'order by `tabBatch`.expiry_date DESC, `tabBatch`.creation ASC',
(item_code, warehouse),