diff --git a/web_sort_menu/README.rst b/web_sort_menu/README.rst new file mode 100644 index 000000000000..c3875c3aee9d --- /dev/null +++ b/web_sort_menu/README.rst @@ -0,0 +1,89 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============= +Web Sort Menu +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f1d56e2c1ad3ffd632fdba68876daefc03d26f76bcfd71126db70a25721d7c07 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/19.0/web_sort_menu + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-19-0/web-19-0-web_sort_menu + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +By default, apps displayed in dropdown menu are sorted alphabetically. +If web_responsive module is installed, apps displayed on NavBar menu is +sorted in alphabetical order. Menus are sorted based on languages used +by users. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to install it. After installation, Apps +displayed on dropdown/NavBar menu will be sorted alphabetically. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Anusri Veerappan Prakasam + +Contributors +------------ + +- Anusri Veerappan Prakasam, Odoo Community Association (OCA) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_sort_menu/__init__.py b/web_sort_menu/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/web_sort_menu/__manifest__.py b/web_sort_menu/__manifest__.py new file mode 100644 index 000000000000..dc43c66fa3f1 --- /dev/null +++ b/web_sort_menu/__manifest__.py @@ -0,0 +1,21 @@ +{ + "name": "Web Sort Menu", + "summary": "Sort Apps in DropDown/NavBar Menu alphabetically", + "version": "19.0.1.0.0", + "category": "Web", + "author": "Anusri Veerappan Prakasam, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web", + "license": "AGPL-3", + "depends": ["web"], + "data": [], + "installable": True, + "assets": { + "web.assets_backend": [ + "web_sort_menu/static/src/js/*.js", + "web_sort_menu/static/src/xml/*.xml", + ], + "web.assets_unit_tests": [ + "web_sort_menu/static/tests/**/*", + ], + }, +} diff --git a/web_sort_menu/i18n/it.po b/web_sort_menu/i18n/it.po new file mode 100644 index 000000000000..c0d5085374bd --- /dev/null +++ b/web_sort_menu/i18n/it.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" diff --git a/web_sort_menu/i18n/web_sort_menu.pot b/web_sort_menu/i18n/web_sort_menu.pot new file mode 100644 index 000000000000..aadee09bfeda --- /dev/null +++ b/web_sort_menu/i18n/web_sort_menu.pot @@ -0,0 +1,13 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" diff --git a/web_sort_menu/pyproject.toml b/web_sort_menu/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/web_sort_menu/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/web_sort_menu/readme/CONTRIBUTORS.md b/web_sort_menu/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..9c9119a49fbe --- /dev/null +++ b/web_sort_menu/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Anusri Veerappan Prakasam, Odoo Community Association (OCA) diff --git a/web_sort_menu/readme/DESCRIPTION.md b/web_sort_menu/readme/DESCRIPTION.md new file mode 100644 index 000000000000..3463228e471d --- /dev/null +++ b/web_sort_menu/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +By default, apps displayed in dropdown menu are sorted alphabetically. +If web_responsive module is installed, apps displayed on NavBar menu is +sorted in alphabetical order. Menus are sorted based on languages used +by users. diff --git a/web_sort_menu/readme/USAGE.md b/web_sort_menu/readme/USAGE.md new file mode 100644 index 000000000000..b2f260192a3a --- /dev/null +++ b/web_sort_menu/readme/USAGE.md @@ -0,0 +1,2 @@ +To use this module, you need to install it. After installation, Apps +displayed on dropdown/NavBar menu will be sorted alphabetically. diff --git a/web_sort_menu/static/description/icon.png b/web_sort_menu/static/description/icon.png new file mode 100644 index 000000000000..1dcc49c24f36 Binary files /dev/null and b/web_sort_menu/static/description/icon.png differ diff --git a/web_sort_menu/static/description/index.html b/web_sort_menu/static/description/index.html new file mode 100644 index 000000000000..9e9254dbc4d8 --- /dev/null +++ b/web_sort_menu/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Web Sort Menu

+ +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

By default, apps displayed in dropdown menu are sorted alphabetically. +If web_responsive module is installed, apps displayed on NavBar menu is +sorted in alphabetical order. Menus are sorted based on languages used +by users.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to install it. After installation, Apps +displayed on dropdown/NavBar menu will be sorted alphabetically.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Anusri Veerappan Prakasam
  • +
+
+
+

Contributors

+
    +
  • Anusri Veerappan Prakasam, Odoo Community Association (OCA)
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/web_sort_menu/static/src/js/sort_app_menu.esm.js b/web_sort_menu/static/src/js/sort_app_menu.esm.js new file mode 100644 index 000000000000..a8c88ca924c5 --- /dev/null +++ b/web_sort_menu/static/src/js/sort_app_menu.esm.js @@ -0,0 +1,8 @@ +import {NavBar} from "@web/webclient/navbar/navbar"; +import {patch} from "@web/core/utils/patch"; + +patch(NavBar.prototype, { + sortApps: (apps) => { + return apps.sort((a, b) => a.name.localeCompare(b.name)); + }, +}); diff --git a/web_sort_menu/static/src/xml/sort_app_menu.xml b/web_sort_menu/static/src/xml/sort_app_menu.xml new file mode 100644 index 000000000000..62b618edae3f --- /dev/null +++ b/web_sort_menu/static/src/xml/sort_app_menu.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/web_sort_menu/static/tests/sort_app_menu.test.js b/web_sort_menu/static/tests/sort_app_menu.test.js new file mode 100644 index 000000000000..56a2334db998 --- /dev/null +++ b/web_sort_menu/static/tests/sort_app_menu.test.js @@ -0,0 +1,23 @@ +import {contains, defineMenus, mountWithCleanup} from "@web/../tests/web_test_helpers"; +import {describe, expect, test} from "@odoo/hoot"; +import {NavBar} from "@web/webclient/navbar/navbar"; +import {queryAllTexts} from "@odoo/hoot-dom"; + +describe.current.tags("desktop"); + +describe("WebSortMenu", () => { + test("apps menu is rendered sorted alphabetically by name", async () => { + defineMenus([ + {id: 1, name: "Zebra"}, + {id: 2, name: "Apple"}, + {id: 3, name: "Mango"}, + ]); + await mountWithCleanup(NavBar); + await contains(".o_navbar_apps_menu button.dropdown-toggle").click(); + expect(queryAllTexts(".o-dropdown--menu .dropdown-item")).toEqual([ + "Apple", + "Mango", + "Zebra", + ]); + }); +}); diff --git a/web_sort_menu/tests/__init__.py b/web_sort_menu/tests/__init__.py new file mode 100644 index 000000000000..0c9e1634eb72 --- /dev/null +++ b/web_sort_menu/tests/__init__.py @@ -0,0 +1 @@ +from . import test_web_sort_menu diff --git a/web_sort_menu/tests/test_web_sort_menu.py b/web_sort_menu/tests/test_web_sort_menu.py new file mode 100644 index 000000000000..df4613e2ffa8 --- /dev/null +++ b/web_sort_menu/tests/test_web_sort_menu.py @@ -0,0 +1,19 @@ +# Copyright 2026 ledoent +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import HttpCase, tagged + + +@tagged("post_install", "-at_install") +class TestWebSortMenu(HttpCase): + def test_js(self): + self.browser_js( + "/web/tests?headless&loglevel=2&preset=desktop&timeout=15000" + "&filter=WebSortMenu", + "", + "", + login="admin", + timeout=1800, + success_signal="[HOOT] Test suite succeeded", + error_checker=lambda x: "[HOOT]" not in x, + )