Skip to content

Commit

Permalink
Merge pull request #329 from nelsonmpanju/version-14
Browse files Browse the repository at this point in the history
feat: Added barcode filter to Item Price by Price List report
  • Loading branch information
miteshpc authored Jun 12, 2024
2 parents 2c9938c + 6f40c37 commit 6da29e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ frappe.query_reports["Item Price by Price List"] = {
"fieldtype": "Percent",
"default": "18",
"mandatory": 1,
}
},
{
"fieldname": "barcode",
"label": __("Scan Barcode"),
"fieldtype": "Data",
"default": "",
"options": "Barcode"
},
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,20 @@ def get_columns():

def get_data(filters):
conditions = ""
if filters.get("item_description"):
conditions += f""" AND (i.description LIKE '%{filters["item_description"]}%' OR i.item_code = '{filters["item_description"]}')"""
if filters.get("barcode"):
# Fetch item code based on barcode
item_code = db.get_value("Item Barcode", {"barcode": filters.get("barcode")}, "parent")
if item_code:
# Fetch and assign the item description to the filters dictionary
item_description = frappe.db.get_value("Item", {"item_code": item_code}, "description")
if item_description:
filters["item_description"] = item_description
else:
frappe.msgprint(_("No description found for item with barcode: ") + filters.get("barcode"), title="Warning")
return [] # Exit function if no description is found

if filters.get("item_description"):
conditions += f" AND (i.description LIKE '%{filters['item_description']}%' OR i.item_code = '{filters['item_description'] or filters.get('barcode')}')"
# Example SQL Query to fetch data
sql = f"""
SELECT
Expand Down

0 comments on commit 6da29e8

Please sign in to comment.