Skip to content

Instantly share code, notes, and snippets.

@itsyosefali
Created January 10, 2023 12:05
Show Gist options
  • Select an option

  • Save itsyosefali/a586aaabddae7da3c490cce7d276d176 to your computer and use it in GitHub Desktop.

Select an option

Save itsyosefali/a586aaabddae7da3c490cce7d276d176 to your computer and use it in GitHub Desktop.
parent_warehouse=""
if filters.get("parent_warehouse"):
escaped_input = frappe.db.escape(filters.get("parent_warehouse"))
parent_warehouse = f" WHERE `tabWarehouse`.parent_warehouse = {escaped_input}"
item_code=""
if filters.get("item_code"):
escaped_input = frappe.db.escape(filters.get("item_code"))
item_code = f" AND `tabBin`.item_code = {escaped_input}"
res = frappe.db.sql(f"""SELECT
`tabWarehouse`.parent_warehouse,
`tabBin`.item_code,
`tabBin`.actual_qty,
`tabBin`.stock_uom
FROM `tabBin`
INNER JOIN `tabWarehouse`
on `tabWarehouse`.name = `tabBin`.warehouse
{parent_warehouse}
{item_code}
""", as_dict=True)
result = res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment