add filters on item prices report (#15495)
This commit is contained in:
parent
b635a71247
commit
171c7d4128
@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
frappe.query_reports["Item Prices"] = {
|
frappe.query_reports["Item Prices"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
|
{
|
||||||
|
"fieldname": "items",
|
||||||
|
"label": __("Items Filter"),
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"options": "Enabled Items only\nDisabled Items only\nAll Items",
|
||||||
|
"default": "Enabled Items only",
|
||||||
|
"on_change": function(query_report) {
|
||||||
|
query_report.trigger_refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ def execute(filters=None):
|
|||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
|
|
||||||
columns = get_columns(filters)
|
columns = get_columns(filters)
|
||||||
item_map = get_item_details()
|
conditions = get_condition(filters)
|
||||||
|
item_map = get_item_details(conditions)
|
||||||
pl = get_price_list()
|
pl = get_price_list()
|
||||||
last_purchase_rate = get_last_purchase_rate()
|
last_purchase_rate = get_last_purchase_rate()
|
||||||
bom_rate = get_item_bom_rate()
|
bom_rate = get_item_bom_rate()
|
||||||
@ -41,14 +42,14 @@ def get_columns(filters):
|
|||||||
|
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
def get_item_details():
|
def get_item_details(conditions):
|
||||||
"""returns all items details"""
|
"""returns all items details"""
|
||||||
|
|
||||||
item_map = {}
|
item_map = {}
|
||||||
|
|
||||||
for i in frappe.db.sql("""select name, item_group, item_name, description,
|
for i in frappe.db.sql("""select name, item_group, item_name, description,
|
||||||
brand, stock_uom from tabItem
|
brand, stock_uom from tabItem %s
|
||||||
order by item_code, item_group""", as_dict=1):
|
order by item_code, item_group""" % (conditions), as_dict=1):
|
||||||
item_map.setdefault(i.name, i)
|
item_map.setdefault(i.name, i)
|
||||||
|
|
||||||
return item_map
|
return item_map
|
||||||
@ -133,3 +134,15 @@ def get_valuation_rate():
|
|||||||
item_val_rate_map.setdefault(d.item_code, d.val_rate)
|
item_val_rate_map.setdefault(d.item_code, d.val_rate)
|
||||||
|
|
||||||
return item_val_rate_map
|
return item_val_rate_map
|
||||||
|
|
||||||
|
def get_condition(filters):
|
||||||
|
"""Get Filter Items"""
|
||||||
|
|
||||||
|
if filters.get("items") == "Enabled Items only":
|
||||||
|
conditions = " where disabled=0 "
|
||||||
|
elif filters.get("items") == "Disabled Items only":
|
||||||
|
conditions = " where disabled=1 "
|
||||||
|
else:
|
||||||
|
conditions = ""
|
||||||
|
|
||||||
|
return conditions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user