From 15f8fe01794101f91b083c28cf7971a7077bbca5 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 24 Nov 2017 10:46:27 +0530 Subject: [PATCH] [fix] Batch selected in the sales transaction for non batch item (#11713) --- erpnext/selling/sales_common.js | 2 +- erpnext/stock/doctype/batch/batch.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 6a148e202a..c8b48a5635 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -355,7 +355,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ */ 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 8d72ac3e2c..6dac64703e 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -149,7 +149,7 @@ def get_batches(item_code, warehouse, qty=1, throw=False): '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),