From d083ddc73e0bfc6732e4e7d873b72347317e7983 Mon Sep 17 00:00:00 2001 From: rocketdebris Date: Thu, 30 Oct 2025 00:34:58 -0400 Subject: [PATCH] Added a custom checkbox to Warehouse Doctype to easily denote sub-status warehouses. --- uberleben_custom/fixtures/custom_field.json | 57 +++++++++++++ .../fixtures/custom_html_block.json | 8 +- uberleben_custom/fixtures/warehouse.json | 82 +++++++++++-------- uberleben_custom/hooks.py | 2 +- 4 files changed, 109 insertions(+), 40 deletions(-) diff --git a/uberleben_custom/fixtures/custom_field.json b/uberleben_custom/fixtures/custom_field.json index 3de02da..5e7b795 100644 --- a/uberleben_custom/fixtures/custom_field.json +++ b/uberleben_custom/fixtures/custom_field.json @@ -55,5 +55,62 @@ "translatable": 0, "unique": 0, "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "Warehouse", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "custom_is_substatus_warehouse", + "fieldtype": "Check", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "is_rejected_warehouse", + "is_system_generated": 0, + "is_virtual": 0, + "label": "Is Sub-Status Warehouse", + "length": 0, + "link_filters": null, + "mandatory_depends_on": null, + "modified": "2025-10-29 21:25:42.717177", + "module": null, + "name": "Warehouse-custom_is_substatus_warehouse", + "no_copy": 0, + "non_negative": 0, + "options": null, + "permlevel": 0, + "placeholder": null, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "show_dashboard": 0, + "sort_options": 0, + "translatable": 0, + "unique": 0, + "width": null } ] \ No newline at end of file diff --git a/uberleben_custom/fixtures/custom_html_block.json b/uberleben_custom/fixtures/custom_html_block.json index b486b74..a7264e0 100644 --- a/uberleben_custom/fixtures/custom_html_block.json +++ b/uberleben_custom/fixtures/custom_html_block.json @@ -2,12 +2,12 @@ { "docstatus": 0, "doctype": "Custom HTML Block", - "html": "
\n Hello, World!\n
\n
", - "modified": "2025-10-29 12:01:13.558369", + "html": "
\n
\n

Filters

\n \n
\n
\n

Items

\n
\n
\n
", + "modified": "2025-10-30 00:31:58.654374", "name": "Inventory Status Workspace", "private": 0, "roles": [], - "script": "frappe.call({\n method: \"uberleben_custom.api.get_item_per_wh\",\n callback: function(r){\n if (r.message) {\n //console.log(r.message);\n populateItemTable(r.message);\n }\n }\n});\n\n function populateItemTable(items) {\n console.log(items);\n console.log(items['Wick and Tindar']);\n var itemTable = root_element.querySelector(\"#item_table\");\n var tableHTML = \"\";\n tableHTML += \"Item IDItem StatusNumber\";\n tableHTML += \"\";\n\n for (const[item, warehouse_data] of Object.entries(items)) {\n for (const[warehouse, amount] of Object.entries(warehouse_data))\n {\n if (amount != null) {\n tableHTML += \"\";\n tableHTML += \"\" + item + \"\";\n tableHTML += \"\" + warehouse + \"\";\n tableHTML += \"\" + amount + \"\";\n }\n }\n \n //tableHTML += \"\" + item.item_group + \"\";\n\n //var statusColor = task.status === \"Overdue\" ? \"red\" : \"green\";\n //tableHTML += \"\" + task.status + \"\";\n\n //var priorityColor = \"\";\n //switch(task.priority) {\n // case \"Urgent\":\n // priorityColor = \"red\";\n // break;\n // case \"High\":\n // priorityColor = \"orange\";\n // break;\n // case \"Medium\":\n // priorityColor = \"#8B8000\";\n // break;\n // case \"Low\":\n // priorityColor = \"green\";\n // break;\n // default:\n // priorityColor = \"inherit\";\n //}\n //tableHTML += \"\" + task.priority + \"\";\n\n //tableHTML += \"\" + task.project + \"\";\n //tableHTML += \"\";\n }\n\n tableHTML += \"\";\n\n itemTable.innerHTML = tableHTML;\n }", - "style": "" + "script": "var warehouse_data;\n\nfrappe.call({\n method: \"uberleben_custom.api.get_warehouse_data\",\n callback: function(r) {\n warehouse_data = r.message;\n }\n});\nfrappe.call({\n method: \"uberleben_custom.api.get_item_per_wh\",\n callback: function(r){\n if (r.message) {\n populateItemTable(r.message);\n }\n }\n});\n\nfunction toggleDetails($rowId) {\n console.log($rowId.attr(\"detail\"));\n if ($rowId.attr(\"detail\")) {\n $rowId.removeAttr(\"detail\");\n }\n else {\n $rowId.attr(\"detail\", true);\n }\n}\n\nfunction toggleInnerTable($tableId) {\n if ($tableId.attr(\"hidden\") != null) {\n $tableId.removeAttr(\"hidden\");\n } else {\n $tableId.attr(\"hidden\", \"\");\n }\n}\n\nfunction generateInnerTableRow(warehouse, number) {\n if (number == 0)\n return \"\"\n return \"\"+warehouse+\"\"+number+\"\";\n}\n\nfunction populateItemTable(items) {\n console.log(\"Prior to building table.\")\n console.log(warehouse_data);\n let $itemTable = $(\"#item_table\", root_element);\n let itemNum = 0;\n let rowNum = 0;\n let tableHTML = \"\";\n tableHTML += \"\";\n tableHTML += \"\";\n\n for (const[item, stock_data] of Object.entries(items)) {\n let rowId = rowNum + \"-row\";\n let rowButtonId = rowId + \"-button\";\n tableHTML += ``;\n tableHTML += ''+item+'';\n tableHTML += \"\";\n for (const[warehouse, number] of Object.entries(stock_data)) {\n let wh = warehouse_data[warehouse]\n if (wh.disabled == 1 || number == 0)\n continue;\n rowId = ++rowNum +\"-row\";\n rowButtonId = rowId + \"-button\";\n if (wh.is_substatus_warehouse == 0) {\n tableHTML += ``;\n tableHTML += ''+warehouse+'Total: '+number;\n if (wh.is_group_warehouse)\n tableHTML += '';\n tableHTML += ''\n tableHTML += '';\n }\n }\n // Generate Inner Nested Table\n let innerTableId = rowNum + \"-table\";\n let innerHTML = ``;\n innerHTML += \"StatusNumber\"\n innerHTML += ``;\n for (const[warehouse, number] of Object.entries(stock_data)) {\n let wh = warehouse_data[warehouse]\n if (wh.disabled == 1)\n continue;\n if (wh.is_substatus_warehouse == 1 && number > 0) {\n innerHTML += '';\n innerHTML += generateInnerTableRow(warehouse, number);\n innerHTML += '';\n }\n }\n innerHTML += \"\";\n tableHTML += innerHTML;\n console.log(innerHTML);\n itemNum++;\n rowNum++;\n }\n\n tableHTML += \"\";\n\n $itemTable.html(tableHTML);\n \n for (let i=0;i {toggleInnerTable($innerTable)});\n }\n }\n }", + "style": ".info-button {\n border-radius: 5px;\n}\n.table-container {\n display:flex;\n}\n\n.table {\n display: flex;\n flex-direction: column;\n}\n\n.outer-table-row {\n display: flex;\n}\n\n.inner-table-row {\n display: flex;\n}" } ] \ No newline at end of file diff --git a/uberleben_custom/fixtures/warehouse.json b/uberleben_custom/fixtures/warehouse.json index a1e4c50..09ab27d 100644 --- a/uberleben_custom/fixtures/warehouse.json +++ b/uberleben_custom/fixtures/warehouse.json @@ -5,6 +5,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 0, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -29,15 +30,16 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 0, "default_in_transit_warehouse": null, - "disabled": 0, + "disabled": 1, "docstatus": 0, "doctype": "Warehouse", "email_id": null, "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-21 16:01:52.467069", + "modified": "2025-10-29 21:56:56.250764", "name": "Stores - U", "old_parent": "All Warehouses - U", "parent_warehouse": "All Warehouses - U", @@ -53,6 +55,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -61,7 +64,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:10:23.322030", + "modified": "2025-10-29 21:26:39.650350", "name": "Work In Progress - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -77,6 +80,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 0, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -85,31 +89,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:10:12.196648", - "name": "Finished Goods - U", - "old_parent": "Uberleben HQ - U", - "parent_warehouse": "Uberleben HQ - U", - "phone_no": null, - "pin": null, - "state": null, - "warehouse_name": "Finished Goods", - "warehouse_type": null - }, - { - "account": null, - "address_line_1": null, - "address_line_2": null, - "city": null, - "company": "Uberleben", - "default_in_transit_warehouse": null, - "disabled": 0, - "docstatus": 0, - "doctype": "Warehouse", - "email_id": null, - "is_group": 0, - "is_rejected_warehouse": 0, - "mobile_no": null, - "modified": "2025-10-21 16:01:52.487226", + "modified": "2025-10-29 22:37:26.274236", "name": "Goods In Transit - U", "old_parent": "All Warehouses - U", "parent_warehouse": "All Warehouses - U", @@ -125,6 +105,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -133,7 +114,7 @@ "is_group": 0, "is_rejected_warehouse": 1, "mobile_no": null, - "modified": "2025-10-28 12:10:00.605806", + "modified": "2025-10-29 21:28:48.692452", "name": "Damaged - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -149,6 +130,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -157,7 +139,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:09:54.087306", + "modified": "2025-10-29 21:28:57.713876", "name": "Receiving - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -173,6 +155,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -181,7 +164,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:09:46.836850", + "modified": "2025-10-29 21:29:05.886880", "name": "QC In Progress - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -197,6 +180,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -205,7 +189,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:09:39.539332", + "modified": "2025-10-29 21:29:12.202231", "name": "QC Hold - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -221,6 +205,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -229,7 +214,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:09:12.219956", + "modified": "2025-10-29 21:29:18.720725", "name": "Staged - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -245,6 +230,7 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, @@ -253,7 +239,7 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-28 12:08:58.548141", + "modified": "2025-10-29 21:29:26.476951", "name": "Inbound - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", @@ -269,15 +255,41 @@ "address_line_2": null, "city": null, "company": "Uberleben", + "custom_is_substatus_warehouse": 1, "default_in_transit_warehouse": null, "disabled": 0, "docstatus": 0, "doctype": "Warehouse", "email_id": null, + "is_group": 0, + "is_rejected_warehouse": 0, + "mobile_no": null, + "modified": "2025-10-29 21:27:40.296954", + "name": "Finished Goods - U", + "old_parent": "Uberleben HQ - U", + "parent_warehouse": "Uberleben HQ - U", + "phone_no": null, + "pin": null, + "state": null, + "warehouse_name": "Finished Goods", + "warehouse_type": null + }, + { + "account": null, + "address_line_1": null, + "address_line_2": null, + "city": null, + "company": "Uberleben", + "custom_is_substatus_warehouse": 0, + "default_in_transit_warehouse": null, + "disabled": 1, + "docstatus": 0, + "doctype": "Warehouse", + "email_id": null, "is_group": 1, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-21 16:01:52.458015", + "modified": "2025-10-29 21:57:07.012733", "name": "All Warehouses - U", "old_parent": "", "parent_warehouse": null, diff --git a/uberleben_custom/hooks.py b/uberleben_custom/hooks.py index 0a1bd9e..d9b46d0 100644 --- a/uberleben_custom/hooks.py +++ b/uberleben_custom/hooks.py @@ -26,7 +26,7 @@ add_to_apps_screen = [ fixtures = [ {"doctype": "Client Script", "filters": [["module", "=", "Uberleben Customizations"]]}, - {"doctype": "Custom Field", "filters": [["dt", "in", "Item"]]}, + {"doctype": "Custom Field", "filters": [["dt", "in", ["Item", "Warehouse"]]]}, "Custom HTML Block", "Warehouse" ]