From 8e9c2bfb7284e6dc4ceb1aac3e8fd048eda78313 Mon Sep 17 00:00:00 2001 From: rocketdebris Date: Thu, 23 Oct 2025 10:46:36 -0400 Subject: [PATCH] Updates to the app, including client scripts and api to get SKU/Warehouse data from the db. --- uberleben_custom/api.py | 18 +++ uberleben_custom/fixtures/client_script.json | 13 ++ uberleben_custom/hooks.py | 121 +++++++++--------- uberleben_custom/public/icon.png | Bin 0 -> 366 bytes .../doctype/__init__.py | 0 .../doctype/item_list.js | 10 ++ .../doctype/stock_item_amount/__init__.py | 0 .../stock_item_amount/stock_item_amount.js | 8 ++ .../stock_item_amount/stock_item_amount.json | 58 +++++++++ .../stock_item_amount/stock_item_amount.py | 9 ++ .../test_stock_item_amount.py | 9 ++ 11 files changed, 189 insertions(+), 57 deletions(-) create mode 100644 uberleben_custom/api.py create mode 100644 uberleben_custom/fixtures/client_script.json create mode 100644 uberleben_custom/public/icon.png create mode 100644 uberleben_custom/uberleben_customizations/doctype/__init__.py create mode 100644 uberleben_custom/uberleben_customizations/doctype/item_list.js create mode 100644 uberleben_custom/uberleben_customizations/doctype/stock_item_amount/__init__.py create mode 100644 uberleben_custom/uberleben_customizations/doctype/stock_item_amount/stock_item_amount.js create mode 100644 uberleben_custom/uberleben_customizations/doctype/stock_item_amount/stock_item_amount.json create mode 100644 uberleben_custom/uberleben_customizations/doctype/stock_item_amount/stock_item_amount.py create mode 100644 uberleben_custom/uberleben_customizations/doctype/stock_item_amount/test_stock_item_amount.py diff --git a/uberleben_custom/api.py b/uberleben_custom/api.py new file mode 100644 index 0000000..8a32abb --- /dev/null +++ b/uberleben_custom/api.py @@ -0,0 +1,18 @@ +import frappe +import erpnext + + +@frappe.whitelist() +def get_item_per_wh(): + items = frappe.db.get_list("Item", pluck="name") + warehouses = frappe.db.get_list("Warehouse", pluck="name") + + data = dict() + + for item in items: + data[item] = dict() + + for item in items: + for warehouse in warehouses: + data[item][warehouse] = erpnext.stock.utils.get_latest_stock_qty(item, warehouse) + return data diff --git a/uberleben_custom/fixtures/client_script.json b/uberleben_custom/fixtures/client_script.json new file mode 100644 index 0000000..c193079 --- /dev/null +++ b/uberleben_custom/fixtures/client_script.json @@ -0,0 +1,13 @@ +[ + { + "docstatus": 0, + "doctype": "Client Script", + "dt": "Item", + "enabled": 1, + "modified": "2025-10-22 10:23:55.971497", + "module": "Uberleben Customizations", + "name": "Update Stock Information", + "script": "frappe.listview_settings[\"Item\"] = frappe.listview_settings[\"Item\"] || {};\n\nfrappe.list_view_settings[\"Item\"].before_render = function() {\n console.log(\"Before Render function.\");\n}", + "view": "List" + } +] \ No newline at end of file diff --git a/uberleben_custom/hooks.py b/uberleben_custom/hooks.py index a70c82e..6297265 100644 --- a/uberleben_custom/hooks.py +++ b/uberleben_custom/hooks.py @@ -11,15 +11,22 @@ app_license = "mit" # required_apps = [] # Each item in the list will be shown as an app in the apps page -# add_to_apps_screen = [ -# { -# "name": "uberleben_custom", -# "logo": "/assets/uberleben_custom/logo.png", -# "title": "Uberleben Customizations", -# "route": "/uberleben_custom", -# "has_permission": "uberleben_custom.api.permission.has_app_permission" -# } -# ] +add_to_apps_screen = [ + { + "name": "uberleben_custom", + "logo": "/assets/uberleben_custom/logo.png", + "title": "Uberleben Customizations", + "route": "/uberleben_custom", + "has_permission": "uberleben_custom.api.permission.has_app_permission" + } +] + +# Fixtures +# ------------------ + +fixtures = [ + {"doctype": "Client Script", "filters": [["module", "=", "Uberleben Customizations"]]} +] # Includes in # ------------------ @@ -61,7 +68,7 @@ app_license = "mit" # website user home page (by Role) # role_home_page = { -# "Role": "home_page" +# "Role": "home_page" # } # Generators @@ -75,8 +82,8 @@ app_license = "mit" # add methods and filters to jinja environment # jinja = { -# "methods": "uberleben_custom.utils.jinja_methods", -# "filters": "uberleben_custom.utils.jinja_filters" +# "methods": "uberleben_custom.utils.jinja_methods", +# "filters": "uberleben_custom.utils.jinja_filters" # } # Installation @@ -118,11 +125,11 @@ app_license = "mit" # Permissions evaluated in scripted ways # permission_query_conditions = { -# "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", +# "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", # } # # has_permission = { -# "Event": "frappe.desk.doctype.event.event.has_permission", +# "Event": "frappe.desk.doctype.event.event.has_permission", # } # DocType Class @@ -130,7 +137,7 @@ app_license = "mit" # Override standard doctype classes # override_doctype_class = { -# "ToDo": "custom_app.overrides.CustomToDo" +# "ToDo": "custom_app.overrides.CustomToDo" # } # Document Events @@ -138,32 +145,32 @@ app_license = "mit" # Hook on document methods and events # doc_events = { -# "*": { -# "on_update": "method", -# "on_cancel": "method", -# "on_trash": "method" -# } +# "*": { +# "on_update": "method", +# "on_cancel": "method", +# "on_trash": "method" +# } # } # Scheduled Tasks # --------------- # scheduler_events = { -# "all": [ -# "uberleben_custom.tasks.all" -# ], -# "daily": [ -# "uberleben_custom.tasks.daily" -# ], -# "hourly": [ -# "uberleben_custom.tasks.hourly" -# ], -# "weekly": [ -# "uberleben_custom.tasks.weekly" -# ], -# "monthly": [ -# "uberleben_custom.tasks.monthly" -# ], +# "all": [ +# "uberleben_custom.tasks.all" +# ], +# "daily": [ +# "uberleben_custom.tasks.daily" +# ], +# "hourly": [ +# "uberleben_custom.tasks.hourly" +# ], +# "weekly": [ +# "uberleben_custom.tasks.weekly" +# ], +# "monthly": [ +# "uberleben_custom.tasks.monthly" +# ], # } # Testing @@ -175,14 +182,14 @@ app_license = "mit" # ------------------------------ # # override_whitelisted_methods = { -# "frappe.desk.doctype.event.event.get_events": "uberleben_custom.event.get_events" +# "frappe.desk.doctype.event.event.get_events": "uberleben_custom.event.get_events" # } # # each overriding function accepts a `data` argument; # generated from the base implementation of the doctype dashboard, # along with any modifications made in other Frappe apps # override_doctype_dashboards = { -# "Task": "uberleben_custom.task.get_dashboard_data" +# "Task": "uberleben_custom.task.get_dashboard_data" # } # exempt linked doctypes from being automatically cancelled @@ -208,37 +215,37 @@ app_license = "mit" # -------------------- # user_data_fields = [ -# { -# "doctype": "{doctype_1}", -# "filter_by": "{filter_by}", -# "redact_fields": ["{field_1}", "{field_2}"], -# "partial": 1, -# }, -# { -# "doctype": "{doctype_2}", -# "filter_by": "{filter_by}", -# "partial": 1, -# }, -# { -# "doctype": "{doctype_3}", -# "strict": False, -# }, -# { -# "doctype": "{doctype_4}" -# } +# { +# "doctype": "{doctype_1}", +# "filter_by": "{filter_by}", +# "redact_fields": ["{field_1}", "{field_2}"], +# "partial": 1, +# }, +# { +# "doctype": "{doctype_2}", +# "filter_by": "{filter_by}", +# "partial": 1, +# }, +# { +# "doctype": "{doctype_3}", +# "strict": False, +# }, +# { +# "doctype": "{doctype_4}" +# } # ] # Authentication and authorization # -------------------------------- # auth_hooks = [ -# "uberleben_custom.auth.validate" +# "uberleben_custom.auth.validate" # ] # Automatically update python controller files with type annotations for this app. # export_python_type_annotations = True # default_log_clearing_doctypes = { -# "Logging DocType Name": 30 # days to retain logs +# "Logging DocType Name": 30 # days to retain logs # } diff --git a/uberleben_custom/public/icon.png b/uberleben_custom/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0279e51d8ac520b67bb3c4ae20d1f2734648759c GIT binary patch literal 366 zcmeAS@N?(olHy`uVBq!ia0vp^G9b*s3?yAI>n{URmH|E?u7ZMs^XJc3P*Avk|2|NR zi;HX3s#QQiAP^7`c>n%=dwcuOpFi{S^Ut3@ucxQCZQC|)Z|}p056268cLOzWmIV0) zPx%i9^E-u85H4AGcad+GM3W&;k^08Z(1hTnhvmyb?b+qre+9CD><8AUv_1n=XhUIa$Ip#}8bzY5YFWxE3y23E*!M=*w0gHK^3pH#7Qr}*8G_+QY8RsffA%b$ZSG`u|t#zr5$n5|KC`DEMF&(3=dNu6{1- HoD!M