From bdd51bc74bc0206c833fcc5e14de2f6d3f1d77e3 Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Thu, 12 Dec 2024 08:35:05 +0100 Subject: [PATCH 1/2] [ADD] web_systray_button_init_action: New module to go to users defined action --- .../addons/web_systray_button_init_action | 1 + setup/web_systray_button_init_action/setup.py | 6 + web_systray_button_init_action/README.rst | 92 ++++ web_systray_button_init_action/__init__.py | 0 .../__manifest__.py | 20 + .../readme/CONFIGURE.rst | 8 + .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 2 + .../static/description/index.html | 440 ++++++++++++++++++ .../static/src/button/button.esm.js | 33 ++ .../static/src/button/button.xml | 17 + .../static/src/tours/tour.esm.js | 41 ++ .../tests/__init__.py | 1 + .../test_web_systray_button_init_action.py | 25 + 14 files changed, 690 insertions(+) create mode 120000 setup/web_systray_button_init_action/odoo/addons/web_systray_button_init_action create mode 100644 setup/web_systray_button_init_action/setup.py create mode 100644 web_systray_button_init_action/README.rst create mode 100644 web_systray_button_init_action/__init__.py create mode 100644 web_systray_button_init_action/__manifest__.py create mode 100644 web_systray_button_init_action/readme/CONFIGURE.rst create mode 100644 web_systray_button_init_action/readme/CONTRIBUTORS.rst create mode 100644 web_systray_button_init_action/readme/DESCRIPTION.rst create mode 100644 web_systray_button_init_action/static/description/index.html create mode 100644 web_systray_button_init_action/static/src/button/button.esm.js create mode 100644 web_systray_button_init_action/static/src/button/button.xml create mode 100644 web_systray_button_init_action/static/src/tours/tour.esm.js create mode 100644 web_systray_button_init_action/tests/__init__.py create mode 100644 web_systray_button_init_action/tests/test_web_systray_button_init_action.py diff --git a/setup/web_systray_button_init_action/odoo/addons/web_systray_button_init_action b/setup/web_systray_button_init_action/odoo/addons/web_systray_button_init_action new file mode 120000 index 000000000000..da6883aae356 --- /dev/null +++ b/setup/web_systray_button_init_action/odoo/addons/web_systray_button_init_action @@ -0,0 +1 @@ +../../../../web_systray_button_init_action \ No newline at end of file diff --git a/setup/web_systray_button_init_action/setup.py b/setup/web_systray_button_init_action/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_systray_button_init_action/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_systray_button_init_action/README.rst b/web_systray_button_init_action/README.rst new file mode 100644 index 000000000000..f905c360480c --- /dev/null +++ b/web_systray_button_init_action/README.rst @@ -0,0 +1,92 @@ +============================== +Web Systray Button Init Action +============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a5303692be5d19ba249d801e0a20b9158db85fbfa20ed596c7ee716f05f60625 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/16.0/web_systray_button_init_action + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_systray_button_init_action + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a button to the navbar to navigate to the initial action if the +user has one defined. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To see the button you need to: + +#. Go to your user. +#. Set debug mode. +#. On Preferences tab, select a Home action. +#. Refresh the screeen. + +The button will be able on systray buttons. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Carlos Roca + * Pedro M. Baeza + +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_systray_button_init_action/__init__.py b/web_systray_button_init_action/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/web_systray_button_init_action/__manifest__.py b/web_systray_button_init_action/__manifest__.py new file mode 100644 index 000000000000..91d9bed16de7 --- /dev/null +++ b/web_systray_button_init_action/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2024 Tecnativa - Carlos Roca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Web Systray Button Init Action", + "summary": "Add a button to go to the user init action.", + "version": "16.0.1.0.0", + "category": "Web", + "website": "https://github.com/OCA/web", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "LGPL-3", + "depends": ["web"], + "assets": { + "web.assets_backend": ["web_systray_button_init_action/static/src/button/*"], + "web.assets_tests": [ + "web_systray_button_init_action/static/src/tours/tour.esm.js", + ], + }, + "installable": True, +} diff --git a/web_systray_button_init_action/readme/CONFIGURE.rst b/web_systray_button_init_action/readme/CONFIGURE.rst new file mode 100644 index 000000000000..a729a2e8d770 --- /dev/null +++ b/web_systray_button_init_action/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +To see the button you need to: + +#. Go to your user. +#. Set debug mode. +#. On Preferences tab, select a Home action. +#. Refresh the screeen. + +The button will be able on systray buttons. \ No newline at end of file diff --git a/web_systray_button_init_action/readme/CONTRIBUTORS.rst b/web_systray_button_init_action/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..7a7dff43668a --- /dev/null +++ b/web_systray_button_init_action/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Carlos Roca + * Pedro M. Baeza \ No newline at end of file diff --git a/web_systray_button_init_action/readme/DESCRIPTION.rst b/web_systray_button_init_action/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..394b0e64ea36 --- /dev/null +++ b/web_systray_button_init_action/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module adds a button to the navbar to navigate to the initial action if the +user has one defined. \ No newline at end of file diff --git a/web_systray_button_init_action/static/description/index.html b/web_systray_button_init_action/static/description/index.html new file mode 100644 index 000000000000..cb2fdf16c0e0 --- /dev/null +++ b/web_systray_button_init_action/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +Web Systray Button Init Action + + + +
+

Web Systray Button Init Action

+ + +

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

+

This module adds a button to the navbar to navigate to the initial action if the +user has one defined.

+

Table of contents

+ +
+

Configuration

+

To see the button you need to:

+
    +
  1. Go to your user.
  2. +
  3. Set debug mode.
  4. +
  5. On Preferences tab, select a Home action.
  6. +
  7. Refresh the screeen.
  8. +
+

The button will be able on systray buttons.

+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Carlos Roca
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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_systray_button_init_action/static/src/button/button.esm.js b/web_systray_button_init_action/static/src/button/button.esm.js new file mode 100644 index 000000000000..3968dd4341c2 --- /dev/null +++ b/web_systray_button_init_action/static/src/button/button.esm.js @@ -0,0 +1,33 @@ +/* @odoo-module */ +/* Copyright 2024 Tecnativa - David Vidal + * Copyright 2024 Tecnativa - Carlos Roca + * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ +import {Component} from "@odoo/owl"; +import {registry} from "@web/core/registry"; +import {useService} from "@web/core/utils/hooks"; +import {session} from "@web/session"; + +export class InitActionMenu extends Component { + setup() { + this.action = useService("action"); + this.showHomeButton = Boolean(session.home_action_id); + } + + /** + * Go to user init action when clicking it + * @private + */ + onClickInitAction() { + window.location.href = window.location.origin + "/web"; + } +} + +InitActionMenu.template = "web_systray_button_init_action.Button"; + +export const systrayInitAction = { + Component: InitActionMenu, +}; + +registry + .category("systray") + .add("web_systray_button_init_action.button", systrayInitAction, {sequence: 100}); diff --git a/web_systray_button_init_action/static/src/button/button.xml b/web_systray_button_init_action/static/src/button/button.xml new file mode 100644 index 000000000000..9efd9ad1c257 --- /dev/null +++ b/web_systray_button_init_action/static/src/button/button.xml @@ -0,0 +1,17 @@ + + + +
+ + + +
+
+
diff --git a/web_systray_button_init_action/static/src/tours/tour.esm.js b/web_systray_button_init_action/static/src/tours/tour.esm.js new file mode 100644 index 000000000000..4a591bf06a54 --- /dev/null +++ b/web_systray_button_init_action/static/src/tours/tour.esm.js @@ -0,0 +1,41 @@ +/** @odoo-module **/ +/* Copyright 2024 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ + +import tour from "web_tour.tour"; + +tour.register( + "web_systray_button_init_action_not_set_tour", + { + url: "/web", + test: true, + }, + [ + { + trigger: ".o_navbar_apps_menu button", + extra_trigger: ":not(:has(a[name='init_action']))", + }, + ] +); +tour.register( + "web_systray_button_init_action_set_tour", + { + url: "/web", + test: true, + }, + [ + { + trigger: ".o_navbar_apps_menu button", + extra_trigger: ".init_action_div:has(a[name='init_action'])", + }, + { + trigger: "a[data-menu-xmlid='base.menu_administration']", + }, + { + trigger: "a[name='init_action']", + }, + { + trigger: ".breadcrumb-item:has(span:contains('Apps'))", + }, + ] +); diff --git a/web_systray_button_init_action/tests/__init__.py b/web_systray_button_init_action/tests/__init__.py new file mode 100644 index 000000000000..adcbcd14ed27 --- /dev/null +++ b/web_systray_button_init_action/tests/__init__.py @@ -0,0 +1 @@ +from . import test_web_systray_button_init_action diff --git a/web_systray_button_init_action/tests/test_web_systray_button_init_action.py b/web_systray_button_init_action/tests/test_web_systray_button_init_action.py new file mode 100644 index 000000000000..c2e0c898f5c6 --- /dev/null +++ b/web_systray_button_init_action/tests/test_web_systray_button_init_action.py @@ -0,0 +1,25 @@ +# Copyright 2024 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from odoo.tests import common, tagged + + +@tagged("post_install", "-at_install") +class TestUI(common.HttpCase): + def test_ui(self): + admin = self.env.ref("base.user_admin") + admin.action_id = False + # Action not set + self.start_tour( + "/web", + "web_systray_button_init_action_not_set_tour", + login="admin", + step_delay=100, + ) + admin.action_id = self.env.ref("base.open_module_tree").id + self.start_tour( + "/web", + "web_systray_button_init_action_set_tour", + login="admin", + step_delay=100, + ) From 3a06051b1c4bca8b46ff45194234daadc3c624fb Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Thu, 12 Dec 2024 08:50:06 +0100 Subject: [PATCH 2/2] [FIX] web_pivot_computed_measure: Add tear_down to avoid incompatibilities with other tests --- web_pivot_computed_measure/tests/test_ui_pivot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web_pivot_computed_measure/tests/test_ui_pivot.py b/web_pivot_computed_measure/tests/test_ui_pivot.py index 4e6d57b8c488..962c243607aa 100644 --- a/web_pivot_computed_measure/tests/test_ui_pivot.py +++ b/web_pivot_computed_measure/tests/test_ui_pivot.py @@ -28,6 +28,11 @@ def setUpClass(cls): action = cls.env.ref("base.action_res_users") action.view_mode += ",pivot" + @classmethod + def tearDownClass(cls): + cls.loader.restore_registry() + return super().tearDownClass() + def test_ui(self): self.start_tour( "/web",