<filename>senstech/senstech/utils.py
# Copyright (c) 2019-2020, libracore and contributors
# For license information, please see license.txt

import frappe
from frappe import _

@frappe.whitelist()
def get_batch_info(item_code):
    sql_query = """SELECT 
          `batches`.`item_code`, 
          `batches`.`batch_no`, 
          `batches`.`qty`,
		   `batches`.`stock_uom`
        FROM (
          SELECT `item_code`, `batch_no`, SUM(`actual_qty`) AS `qty`, `stock_uom`
          FROM `tabStock Ledger Entry`        
          WHERE `item_code` = '{item_code}'
          GROUP BY `batch_no`) AS `batches`
        LEFT JOIN `tabItem` ON `tabItem`.`item_code` = `batches`.`item_code`
        WHERE `qty` > 0;""".format(item_code=item_code)
    
    data = frappe.db.sql(sql_query, as_dict=1)
    return data

<filename>senstech/senstech/utils.py
# Copyright (c) 2019-2020, libracore and contributors
# For license information, please see license.txt

import frappe
from frappe import _

@frappe.whitelist()
def get_batch_info(item_code):
    sql_query = """SELECT 
          `batches`.`item_code`, 
          `batches`.`batch_no`, 
          `batches`.`qty`,
		   `batches`.`stock_uom`
        FROM (
          SELECT `item_code`, `batch_no`, SUM(`actual_qty`) AS `qty`, `stock_uom`
          FROM `tabStock Ledger Entry`        
          WHERE `item_code` = '{item_code}'
          GROUP BY `batch_no`) AS `batches`
        LEFT JOIN `tabItem` ON `tabItem`.`item_code` = `batches`.`item_code`
        WHERE `qty` > 0;""".format(item_code=item_code)
    
    data = frappe.db.sql(sql_query, as_dict=1)
    return data

# Copyright (c) 2019-2020, libracore and contributors # For license information, please see license.txt SELECT            `batches`.`item_code`,            `batches`.`batch_no`,            `batches`.`qty`, 		   `batches`.`stock_uom`         FROM (           SELECT `item_code`, `batch_no`, SUM(`actual_qty`) AS `qty`, `stock_uom`           FROM `tabStock Ledger Entry`                   WHERE `item_code` = '{item_code}'           GROUP BY `batch_no`) AS `batches`         LEFT JOIN `tabItem` ON `tabItem`.`item_code` = `batches`.`item_code`         WHERE `qty` > 0;