diff --git a/uberleben_custom/api.py b/uberleben_custom/api.py index 089f0d9..0056590 100644 --- a/uberleben_custom/api.py +++ b/uberleben_custom/api.py @@ -3,21 +3,24 @@ import erpnext @frappe.whitelist() -def get_item_per_wh(): - items = frappe.db.get_list("Item", pluck="name") +def get_item_per_wh(filters={}): + items = frappe.db.get_list("Item", fields=["name", "item_group"], filters=filters) warehouses = frappe.db.get_list("Warehouse", pluck="name") data = dict() for item in items: - data[item] = dict() + item_name = item['name'] + item_group = item['item_group'] + data[item_name] = dict(item_group=item_group, warehouses=dict()) for item in items: + item_name = item["name"] for warehouse in warehouses: - quantity = erpnext.stock.utils.get_latest_stock_qty(item, warehouse) + quantity = erpnext.stock.utils.get_latest_stock_qty(item_name, warehouse) if quantity is None: quantity = 0 - data[item][warehouse] = quantity # erpnext.stock.utils.get_latest_stock_qty(item, warehouse) + data[item_name]['warehouses'][warehouse] = quantity return data @@ -33,3 +36,8 @@ def get_warehouse_data(): data[warehouse]['disabled'] = doc.disabled data[warehouse]['is_group_warehouse'] = doc.is_group return data + + +@frappe.whitelist() +def get_item_groups(): + return frappe.db.get_list("Item Group", pluck="name") diff --git a/uberleben_custom/fixtures/custom_html_block.json b/uberleben_custom/fixtures/custom_html_block.json index 7b5d97f..0971491 100644 --- a/uberleben_custom/fixtures/custom_html_block.json +++ b/uberleben_custom/fixtures/custom_html_block.json @@ -3,11 +3,11 @@ "docstatus": 0, "doctype": "Custom HTML Block", "html": "
| Status | Number |